forked from infinispan/infinispan
-
Notifications
You must be signed in to change notification settings - Fork 5
101 lines (91 loc) · 3.88 KB
/
on_build_do_publish_image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Publish Image
run-name: ${{ github.event.workflow_run.display_title }}
on:
workflow_run:
workflows: [Build]
types: [completed]
env:
IMAGE_NAME: ${{ vars.QUAY_IMAGE_NAME || 'quay.io/infinispan-test/server' }}
concurrency:
# Cancel jobs same head_branch same repo, works
# both for pull_request and push
group: >
${{ github.workflow }}-${{ github.event.workflow_run.head_repository.full_name }}-
${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
jobs:
get-info:
if: github.event.workflow_run.conclusion == 'success'
name: Get Origin Workflow Info
runs-on: ubuntu-latest
outputs:
source-head-sha: ${{ github.event.workflow_run.head_sha }}
pull-request-number: ${{ steps.workflow-run-info.outputs.pull-request-number }}
sourceEvent: ${{ github.event.workflow_run.event }}
image-tag: ${{ steps.workflow-run-info.outputs.image-tag }}
publish-image: ${{ steps.publish-image-info.outputs.publish-image }}
image-name: ${{ steps.image-name.outputs.image-name }}
steps:
- uses: actions/checkout@v4
- id: workflow-run-info
uses: ./.github/actions/get-origin-info
with:
head-sha: ${{ github.event.workflow_run.head_sha }}
head-branch: ${{ github.event.workflow_run.head_branch }}
event: ${{ github.event.workflow_run.event }}
- if: ${{ github.event.workflow_run.event == 'pull_request' }}
name: Get Labels Action
uses: snnaplab/get-labels-action@v1.0.1
with:
number: ${{ steps.workflow-run-info.outputs.pull-request-number }}
- if: >
github.event.workflow_run.event == 'push'
|| github.event.workflow_run.event == 'pull_request'
&& contains(fromJSON(env.LABELS), 'pr/Image Required')
id: publish-image-info
run: echo "publish-image=true" >> $GITHUB_OUTPUT
- name: Propagate env vars
id: image-name
run: echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT
- name: set-commit-status
if: steps.publish-image-info.outputs.publish-image == 'true'
uses: myrotvorets/set-commit-status-action@v2.0.1
with:
status: pending
sha: ${{ github.event.workflow_run.head_sha }}
targetUrl: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
publish-image:
needs:
- get-info
if: needs.get-info.outputs.publish-image == 'true'
uses: infinispan/infinispan-images/.github/workflows/publish_image.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
quayUser: ${{ secrets.QUAY_USERNAME_TEST }}
quayPass: ${{ secrets.QUAY_TOKEN_TEST }}
with:
repository: ${{ github.repository }}
runId: ${{ github.event.workflow_run.id }}
serverArtifact: infinispan-dist
tags: ${{ needs.get-info.outputs.image-name }}:gh-${{ needs.get-info.outputs.image-tag }}
report-status:
runs-on: ubuntu-latest
needs:
- get-info
- publish-image
if: always() && needs.get-info.outputs.publish-image == 'true'
steps:
- name: set-commit-status
if: ${{ needs.publish-image.result == 'success'}}
uses: myrotvorets/set-commit-status-action@v2.0.1
with:
status: success
sha: ${{ needs.get-info.outputs.source-head-sha }}
targetUrl: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: set-commit-status
if: ${{ needs.publish-image.result != 'success'}}
uses: myrotvorets/set-commit-status-action@v2.0.1
with:
status: failure
sha: ${{ needs.get-info.outputs.source-head-sha }}
targetUrl: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}