|
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-cli |
10 | | - WF_ORG: netobserv |
11 | 10 |
|
12 | 11 | jobs: |
13 | 12 | push-pr-image: |
14 | | - 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' |
15 | 16 | name: push PR image |
16 | 17 | runs-on: ubuntu-latest |
17 | 18 | steps: |
18 | | - - name: install make |
19 | | - run: sudo apt-get install make |
20 | | - - name: set up go 1.x |
21 | | - uses: actions/setup-go@v3 |
| 19 | + - name: download artifact |
| 20 | + uses: actions/download-artifact@v5 |
22 | 21 | with: |
23 | | - go-version: '1.25' |
24 | | - - name: checkout |
25 | | - uses: actions/checkout@v3 |
26 | | - with: |
27 | | - 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 ./image.tar |
28 | 28 | - name: docker login to quay.io |
29 | 29 | uses: docker/login-action@v2 |
30 | 30 | with: |
31 | 31 | username: ${{ env.WF_REGISTRY_USER }} |
32 | 32 | password: ${{ secrets.QUAY_SECRET }} |
33 | 33 | registry: quay.io |
34 | | - - name: get short sha |
35 | | - run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
36 | | - - name: build and push manifest with images |
37 | | - 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 images |
38 | | - - name: make commands |
39 | | - run: USER=netobserv VERSION=${{ env.short_sha }} make commands |
40 | | - - name: upload commands |
41 | | - id: artifact-upload-step |
42 | | - uses: actions/upload-artifact@v4 |
43 | | - with: |
44 | | - name: commands |
45 | | - path: build |
| 34 | + - name: push images |
| 35 | + run: | |
| 36 | + DOCKER_BUILDKIT=1 docker push $(cat ./name) |
46 | 37 | - uses: actions/github-script@v6 |
47 | 38 | with: |
48 | 39 | github-token: ${{secrets.GITHUB_TOKEN}} |
49 | 40 | script: | |
| 41 | + var fs = require('fs'); |
| 42 | + var issueNumber = Number(fs.readFileSync('./pr-id')); |
| 43 | + var shortSha = String(fs.readFileSync('./short-sha')).trim(); |
| 44 | + var mainImage = fs.readFileSync('./name'); |
| 45 | + var commandsURL = fs.readFileSync('./commands-url'); |
50 | 46 | github.rest.issues.createComment({ |
51 | | - issue_number: context.issue.number, |
| 47 | + issue_number: issueNumber, |
52 | 48 | owner: context.repo.owner, |
53 | 49 | repo: context.repo.repo, |
54 | 50 | body: `New image: |
55 | | - ${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} |
| 51 | + \`\`\`bash |
| 52 | + ${mainImage} |
| 53 | + \`\`\` |
56 | 54 |
|
57 | | - It will expire after two weeks. |
| 55 | + It will expire in two weeks. |
58 | 56 |
|
59 | 57 | To use this build, update your commands using: |
60 | 58 | \`\`\`bash |
61 | | - USER=netobserv VERSION=${{ env.short_sha }} make commands |
| 59 | + USER=netobserv VERSION=${shortSha} make commands |
62 | 60 | \`\`\` |
63 | 61 | |
64 | | - or [download the updated commands](${{ steps.artifact-upload-step.outputs.artifact-url }}). |
| 62 | + or [download the updated commands](${commandsURL}). |
65 | 63 | ` |
66 | 64 | }) |
0 commit comments