1- # Build & Publish GitHub Container Registry (GHCR) Images
2- name : Deploy and Test
1+ # Build and publish GitHub Container Registry (GHCR) images after tests pass.
2+ name : Deploy
33permissions :
44 contents : write
55 packages : write
1111 FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
1212
1313concurrency :
14- group : gemc-images -${{ github.ref }}
14+ group : gemc-deploy -${{ github.event.workflow_run.id }}
1515 cancel-in-progress : true
1616
1717on :
18- # Allows this workflow to be triggered from other repositories (e.g. pygemc)
19- workflow_dispatch :
20-
21- pull_request :
22- paths-ignore :
23- - " **/README*"
24- - " **/LICENSE*"
25- - " **/CODE_OF_CONDUCT.md"
26- - " **/CONTRIBUTING.md"
27- - " **/SECURITY.md"
28- merge_group :
29- push :
30- branches : [ main ]
31- tags : [ '*' ]
32- paths-ignore :
33- - " **/*.md"
34- - " **/README*"
35- - " **/CODE_OF_CONDUCT.md"
36- - " **/CONTRIBUTING.md"
37- - " **/SECURITY.md"
38- - " releases/**"
39- - " doc/**"
18+ workflow_run :
19+ workflows : [ "Test" ]
20+ types : [ completed ]
4021
4122jobs :
4223 overview :
43- if : ${{ github.event_name != 'pull_request' }}
24+ if : >-
25+ ${{
26+ github.event.workflow_run.conclusion == 'success' &&
27+ github.event.workflow_run.event == 'push'
28+ }}
4429 name : Workflow Overview
4530 runs-on : ubuntu-latest
4631 steps :
4732 - name : Checkout repository
4833 uses : actions/checkout@v6
34+ with :
35+ ref : ${{ github.event.workflow_run.head_sha }}
4936
5037 - name : Write overview
5138 shell : bash
5441 bash ci/summary.sh "$GITHUB_STEP_SUMMARY"
5542
5643 discover :
57- if : ${{ github.event_name != 'pull_request' }}
44+ if : >-
45+ ${{
46+ github.event.workflow_run.conclusion == 'success' &&
47+ github.event.workflow_run.event == 'push'
48+ }}
5849 name : Create Job Matrices
5950 runs-on : ubuntu-latest
6051 outputs :
@@ -64,14 +55,15 @@ jobs:
6455 steps :
6556 - name : Checkout repository
6657 uses : actions/checkout@v6
58+ with :
59+ ref : ${{ github.event.workflow_run.head_sha }}
6760 - id : scan
6861 name : Build matrix
6962 run : ci/distros_tags.sh
7063
7164 # arch build jobs
7265 # uses matrix_build
7366 build_arch :
74- if : ${{ github.event_name != 'pull_request' }}
7567 name : ${{ matrix.image }}/${{ matrix.image_tag }} ${{ matrix.arch }}
7668 needs : [ overview, discover ]
7769 runs-on : ${{ matrix.runner }}
8880 steps :
8981 - name : Checkout repository
9082 uses : actions/checkout@v6
83+ with :
84+ ref : ${{ github.event.workflow_run.head_sha }}
85+ fetch-depth : 0
9186
9287 - name : Free up disk space
9388 uses : ./.github/actions/free-disk-space
@@ -114,7 +109,7 @@ jobs:
114109 type=raw,value=${{ env.TAG4 }}
115110 labels : |
116111 org.opencontainers.image.source=${{ github.repository }}
117- org.opencontainers.image.description=GEMC ${{ matrix.gemc_tag }} on ${{ matrix.image }}:${{ matrix.image_tag }} (${{ matrix. arch }})
112+ org.opencontainers.image.description=GEMC ${{ matrix.gemc_tag }} ${{ matrix.arch }}
118113
119114 - name : Generate Dockerfile
120115 run : |
@@ -124,23 +119,18 @@ jobs:
124119 --gemc-version "${{ matrix.gemc_tag || env.GEMC_TAG }}" \
125120 --geant4-version "${{ matrix.geant4_tag || env.GEANT4_TAG }}" \
126121 --with-package \
122+ --source context \
127123 --package-arch "${{ matrix.arch }}" \
128124 > Dockerfile.generated
129125 cat Dockerfile.generated
130126
131- # later pass it in the step below so that it's executed for every commit
132- - name : Get upstream commit
133- run : echo "UPSTREAM_REV=$(git ls-remote https://github.com/gemc/src HEAD | cut -f1)" >> $GITHUB_ENV
134-
135127 - name : Build & Push
136128 uses : docker/build-push-action@v7
137129 with :
138130 # ensure we have the latest base image
139131 pull : true
140132 # force a full rebuild regardless of any local cache from previous workflow runs
141133 no-cache : true
142- build-args : |
143- UPSTREAM_REV=${{ env.UPSTREAM_REV }}
144134 context : .
145135 file : ./Dockerfile.generated
146136 target : final
@@ -205,7 +195,6 @@ jobs:
205195 # docker buildx imagetools create: assembles an OCI manifest list
206196 # from already-pushed per-arch image tags.
207197 manifest :
208- if : ${{ github.event_name != 'pull_request' }}
209198 name : ${{ matrix.image }}/${{ matrix.image_tag }}
210199 needs : [ build_arch, discover ]
211200 runs-on : ubuntu-latest
@@ -218,6 +207,8 @@ jobs:
218207 steps :
219208 - name : Checkout repository
220209 uses : actions/checkout@v6
210+ with :
211+ ref : ${{ github.event.workflow_run.head_sha }}
221212
222213 - name : Log in to GHCR
223214 uses : docker/login-action@v4
@@ -281,3 +272,24 @@ jobs:
281272 name : summary-${{ env.TAG4 }}-manifest
282273 path : ${{ env.MANIFEST_SUMMARY_FILE }}
283274 if-no-files-found : warn
275+
276+ final :
277+ name : Deploy - summary
278+ if : >-
279+ ${{
280+ always() &&
281+ github.event.workflow_run.conclusion == 'success' &&
282+ github.event.workflow_run.event == 'push'
283+ }}
284+ needs : [ build_arch, manifest ]
285+ runs-on : ubuntu-latest
286+ steps :
287+ - name : Fail if any required job failed
288+ if : ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
289+ run : |
290+ echo "### Some GEMC deploy jobs failed or were cancelled." >> "$GITHUB_STEP_SUMMARY"
291+ exit 1
292+
293+ - name : Pass
294+ run : |
295+ echo "### GEMC deploy workflow passed." >> "$GITHUB_STEP_SUMMARY"
0 commit comments