|
1 | | -name: Build and push PR image to quay.io |
| 1 | +name: Push PR image to quay.io |
2 | 2 | on: |
3 | | - pull_request_target: |
4 | | - types: [labeled] |
| 3 | + workflow_run: |
| 4 | + workflows: ["Build PR image and upload artifact"] |
| 5 | + types: |
| 6 | + - completed |
5 | 7 |
|
6 | 8 | env: |
7 | 9 | WF_REGISTRY_USER: netobserv+github_ci |
8 | | - WF_REGISTRY: quay.io/netobserv |
9 | | - WF_IMAGE: network-observability-operator |
10 | | - WF_ORG: netobserv |
11 | | - WF_RELIMG_VERSION: main |
12 | 10 |
|
13 | 11 | jobs: |
14 | 12 | push-pr-image: |
15 | | - if: ${{ github.event.label.name == 'ok-to-test' }} |
| 13 | + if: > |
| 14 | + github.event.workflow_run.event == 'pull_request' && |
| 15 | + github.event.workflow_run.conclusion == 'success' |
16 | 16 | name: push PR image |
17 | 17 | runs-on: ubuntu-latest |
18 | 18 | steps: |
19 | | - - name: install make |
20 | | - run: sudo apt-get install make |
21 | | - - name: set up go 1.x |
22 | | - uses: actions/setup-go@v3 |
| 19 | + - name: download artifact |
| 20 | + uses: actions/download-artifact@v5 |
23 | 21 | with: |
24 | | - go-version: '1.25' |
25 | | - - name: checkout |
26 | | - uses: actions/checkout@v3 |
27 | | - with: |
28 | | - ref: "refs/pull/${{ github.event.number }}/merge" |
| 22 | + name: pr |
| 23 | + run-id: ${{github.event.workflow_run.id }} |
| 24 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 25 | + - name: load images |
| 26 | + run: | |
| 27 | + docker load --input ./operator.tar |
| 28 | + docker load --input ./bundle.tar |
29 | 29 | - name: docker login to quay.io |
30 | 30 | uses: docker/login-action@v2 |
31 | 31 | with: |
32 | 32 | username: ${{ env.WF_REGISTRY_USER }} |
33 | 33 | password: ${{ secrets.QUAY_SECRET }} |
34 | 34 | registry: quay.io |
35 | | - - name: get short sha |
36 | | - run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
37 | | - - name: build image |
38 | | - run: OCI_BUILD_OPTS="--label quay.expires-after=2w" IMAGE_ORG=${{ env.WF_ORG }} IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} CLEAN_BUILD=1 make image-build |
39 | | - - name: push image |
40 | | - run: IMAGE_ORG=${{ env.WF_ORG }} IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} make image-push |
41 | | - - name: build and push manifest |
42 | | - run: IMAGE_ORG=${{ env.WF_ORG }} IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} make manifest-build manifest-push |
43 | | - - name: get related images target |
44 | | - if: startsWith(github.ref_name, 'release-') |
| 35 | + - name: push operator and bundle |
45 | 36 | run: | |
46 | | - echo "WF_RELIMG_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV |
47 | | - - name: build bundle |
48 | | - run: OCI_BUILD_OPTS="--label quay.expires-after=2w" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.short_sha }} PLG_VERSION=${{ env.WF_RELIMG_VERSION }} FLP_VERSION=${{ env.WF_RELIMG_VERSION }} BPF_VERSION=${{ env.WF_RELIMG_VERSION }} BUNDLE_VERSION=0.0.0-sha-${{ env.short_sha }} CLEAN_BUILD=1 BUNDLE_SET_DATE=true make bundle bundle-build |
49 | | - - name: push bundle to quay.io |
50 | | - run: IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.short_sha }} BUNDLE_VERSION=0.0.0-sha-${{ env.short_sha }} make bundle-push |
51 | | - - name: build catalog |
52 | | - run: IMAGE_ORG=${{ env.WF_ORG }} BUNDLE_VERSION=0.0.0-sha-${{ env.short_sha }} make shortlived-catalog-build |
53 | | - - name: push catalog to quay.io |
54 | | - run: IMAGE_ORG=${{ env.WF_ORG }} BUNDLE_VERSION=0.0.0-sha-${{ env.short_sha }} make catalog-push |
55 | | - - uses: actions/github-script@v5 |
| 37 | + DOCKER_BUILDKIT=1 docker push $(cat ./operator-name) |
| 38 | + DOCKER_BUILDKIT=1 docker push $(cat ./bundle-name) |
| 39 | + - name: build and push catalog |
| 40 | + run: | |
| 41 | + IMAGE_ORG=${{ env.WF_ORG }} BUNDLE_VERSION=0.0.0-sha-$(cat ./short-sha) make shortlived-catalog-build catalog-push |
| 42 | + - uses: actions/github-script@v6 |
56 | 43 | with: |
57 | 44 | github-token: ${{secrets.GITHUB_TOKEN}} |
58 | 45 | script: | |
| 46 | + var fs = require('fs'); |
| 47 | + var issueNumber = Number(fs.readFileSync('./pr-id')); |
| 48 | + var shortSha = String(fs.readFileSync('./short-sha')).trim(); |
| 49 | + var operatorImage = fs.readFileSync('./operator-name'); |
| 50 | + var bundleImage = fs.readFileSync('./bundle-name'); |
59 | 51 | github.rest.issues.createComment({ |
60 | | - issue_number: context.issue.number, |
| 52 | + issue_number: issueNumber, |
61 | 53 | owner: context.repo.owner, |
62 | 54 | repo: context.repo.repo, |
63 | 55 | body: `New images: |
64 | | - * ${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} |
65 | | - * ${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}-bundle:v0.0.0-sha-${{ env.short_sha }} |
66 | | - * ${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}-catalog:v0.0.0-sha-${{ env.short_sha }} |
| 56 | + \`\`\`bash |
| 57 | + ${operatorImage} |
| 58 | + ${bundleImage} |
| 59 | + quay.io/netobserv/network-observability-operator-catalog:v0.0.0-sha-${shortSha} |
| 60 | + \`\`\` |
67 | 61 |
|
68 | | - They will expire after two weeks. |
| 62 | + They will expire in two weeks. |
69 | 63 |
|
70 | 64 | To deploy this build: |
71 | 65 | \`\`\`bash |
72 | 66 | # Direct deployment, from operator repo |
73 | | - IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} make deploy |
| 67 | + IMAGE=${operatorImage} make deploy |
74 | 68 |
|
75 | 69 | # Or using operator-sdk |
76 | | - operator-sdk run bundle ${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}-bundle:v0.0.0-sha-${{ env.short_sha }} |
| 70 | + operator-sdk run bundle ${bundleImage} |
77 | 71 | \`\`\` |
78 | 72 |
|
79 | 73 | Or as a Catalog Source: |
|
85 | 79 | namespace: openshift-marketplace |
86 | 80 | spec: |
87 | 81 | sourceType: grpc |
88 | | - image: ${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}-catalog:v0.0.0-sha-${{ env.short_sha }} |
| 82 | + image: quay.io/netobserv/network-observability-operator-catalog:v0.0.0-sha-${shortSha} |
89 | 83 | displayName: NetObserv development catalog |
90 | 84 | publisher: Me |
91 | 85 | updateStrategy: |
|
0 commit comments