@@ -42,13 +42,13 @@ jobs:
4242
4343 strategy :
4444 matrix :
45- isPr :
46- - ${{ github.event_name == 'pull_request' }}
4745 # Architectures / Platforms for which we will build Docker images
48- # If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
49- # If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64.
5046 arch : ['linux/amd64', 'linux/arm64']
5147 os : [ubuntu-latest]
48+ isPr :
49+ - ${{ github.event_name == 'pull_request' }}
50+ # If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
51+ # The below exclude therefore ensures we do NOT build ARM64 for PRs.
5252 exclude :
5353 - isPr : true
5454 os : ubuntu-latest
@@ -58,21 +58,21 @@ jobs:
5858 steps :
5959 # https://github.com/actions/checkout
6060 - name : Checkout codebase
61- uses : actions/checkout@v3
61+ uses : actions/checkout@v4
6262
6363 # https://github.com/docker/setup-buildx-action
6464 - name : Setup Docker Buildx
65- uses : docker/setup-buildx-action@v2
65+ uses : docker/setup-buildx-action@v3
6666
6767 # https://github.com/docker/setup-qemu-action
6868 - name : Set up QEMU emulation to build for multiple architectures
69- uses : docker/setup-qemu-action@v2
69+ uses : docker/setup-qemu-action@v3
7070
7171 # https://github.com/docker/login-action
7272 - name : Login to DockerHub
7373 # Only login if not a PR, as PRs only trigger a Docker build and not a push
7474 if : ${{ ! matrix.isPr }}
75- uses : docker/login-action@v2
75+ uses : docker/login-action@v3
7676 with :
7777 username : ${{ secrets.DOCKER_USERNAME }}
7878 password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
8181 # Get Metadata for docker_build step below
8282 - name : Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular' image
8383 id : meta_build
84- uses : docker/metadata-action@v4
84+ uses : docker/metadata-action@v5
8585 with :
8686 images : ${{ env.REGISTRY_IMAGE }}
8787 tags : ${{ env.IMAGE_TAGS }}
9090 # https://github.com/docker/build-push-action
9191 - name : Build and push 'dspace-angular' image
9292 id : docker_build
93- uses : docker/build-push-action@v4
93+ uses : docker/build-push-action@v5
9494 with :
9595 context : .
9696 file : ./Dockerfile
@@ -102,13 +102,15 @@ jobs:
102102 tags : ${{ steps.meta_build.outputs.tags }}
103103 labels : ${{ steps.meta_build.outputs.labels }}
104104
105+ # Export the digest of Docker build locally (for non PRs only)
105106 - name : Export digest
106107 if : ${{ ! matrix.isPr }}
107108 run : |
108109 mkdir -p /tmp/digests
109110 digest="${{ steps.docker_build.outputs.digest }}"
110111 touch "/tmp/digests/${digest#sha256:}"
111112
113+ # Upload digest to an artifact, so that it can be used in manifest below
112114 - name : Upload digest
113115 if : ${{ ! matrix.isPr }}
114116 uses : actions/upload-artifact@v3
@@ -118,7 +120,12 @@ jobs:
118120 if-no-files-found : error
119121 retention-days : 1
120122
121- merge :
123+ # Merge digests into a manifest.
124+ # This runs after all Docker builds complete above, and it tells hub.docker.com
125+ # that these builds should be all included in the manifest for this tag.
126+ # (e.g. AMD64 and ARM64 should be listed as options under the same tagged Docker image)
127+ # Borrowed from https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
128+ dspace-angular_manifest :
122129 if : ${{ github.event_name != 'pull_request' }}
123130 runs-on : ubuntu-latest
124131 needs :
@@ -129,9 +136,11 @@ jobs:
129136 with :
130137 name : digests
131138 path : /tmp/digests
139+
132140 - name : Set up Docker Buildx
133141 uses : docker/setup-buildx-action@v3
134- - name : Docker meta
142+
143+ - name : Add Docker metadata for image
135144 id : meta
136145 uses : docker/metadata-action@v5
137146 with :
@@ -145,7 +154,7 @@ jobs:
145154 username : ${{ secrets.DOCKER_USERNAME }}
146155 password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
147156
148- - name : Create manifest list and push
157+ - name : Create manifest list from digests and push
149158 working-directory : /tmp/digests
150159 run : |
151160 docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
@@ -164,13 +173,13 @@ jobs:
164173
165174 strategy :
166175 matrix :
167- isPr :
168- - ${{ github.event_name == 'pull_request' }}
169176 # Architectures / Platforms for which we will build Docker images
170- # If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
171- # If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64.
172177 arch : ['linux/amd64', 'linux/arm64']
173178 os : [ubuntu-latest]
179+ isPr :
180+ - ${{ github.event_name == 'pull_request' }}
181+ # If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
182+ # The below exclude therefore ensures we do NOT build ARM64 for PRs.
174183 exclude :
175184 - isPr : true
176185 os : ubuntu-latest
@@ -180,21 +189,21 @@ jobs:
180189 steps :
181190 # https://github.com/actions/checkout
182191 - name : Checkout codebase
183- uses : actions/checkout@v3
192+ uses : actions/checkout@v4
184193
185194 # https://github.com/docker/setup-buildx-action
186195 - name : Setup Docker Buildx
187- uses : docker/setup-buildx-action@v2
196+ uses : docker/setup-buildx-action@v3
188197
189198 # https://github.com/docker/setup-qemu-action
190199 - name : Set up QEMU emulation to build for multiple architectures
191- uses : docker/setup-qemu-action@v2
200+ uses : docker/setup-qemu-action@v3
192201
193202 # https://github.com/docker/login-action
194203 - name : Login to DockerHub
195204 # Only login if not a PR, as PRs only trigger a Docker build and not a push
196205 if : ${{ ! matrix.isPr }}
197- uses : docker/login-action@v2
206+ uses : docker/login-action@v3
198207 with :
199208 username : ${{ secrets.DOCKER_USERNAME }}
200209 password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
@@ -203,7 +212,7 @@ jobs:
203212 # Get Metadata for docker_build_dist step below
204213 - name : Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular-dist' image
205214 id : meta_build_dist
206- uses : docker/metadata-action@v4
215+ uses : docker/metadata-action@v5
207216 with :
208217 images : ${{ env.REGISTRY_IMAGE }}
209218 tags : ${{ env.IMAGE_TAGS }}
@@ -214,7 +223,7 @@ jobs:
214223
215224 - name : Build and push 'dspace-angular-dist' image
216225 id : docker_build_dist
217- uses : docker/build-push-action@v4
226+ uses : docker/build-push-action@v5
218227 with :
219228 context : .
220229 file : ./Dockerfile.dist
@@ -226,36 +235,46 @@ jobs:
226235 tags : ${{ steps.meta_build_dist.outputs.tags }}
227236 labels : ${{ steps.meta_build_dist.outputs.labels }}
228237
238+ # Export the digest of Docker build locally (for non PRs only)
229239 - name : Export digest
230240 if : ${{ ! matrix.isPr }}
231241 run : |
232242 mkdir -p /tmp/digests/dist
233243 digest="${{ steps.docker_build_dist.outputs.digest }}"
234244 touch "/tmp/digests/dist/${digest#sha256:}"
235245
246+ # Upload Digest to an artifact, so that it can be used in manifest below
236247 - name : Upload digest
237248 if : ${{ ! matrix.isPr }}
238249 uses : actions/upload-artifact@v3
239250 with :
240- name : digests
241- path : /tmp/digests/dist/*
251+ # NOTE: It's important that this artifact has a unique name so that two
252+ # image builds don't upload digests to the same artifact.
253+ name : digests-dist
254+ path : /tmp/digests/*
242255 if-no-files-found : error
243256 retention-days : 1
244257
245- merge-dist :
258+ # Merge *-dist digests into a manifest.
259+ # This runs after all Docker builds complete above, and it tells hub.docker.com
260+ # that these builds should be all included in the manifest for this tag.
261+ # (e.g. AMD64 and ARM64 should be listed as options under the same tagged Docker image)
262+ dspace-angular-dist_manifest :
246263 if : ${{ github.event_name != 'pull_request' }}
247264 runs-on : ubuntu-latest
248265 needs :
249266 - dspace-angular-dist
250267 steps :
251- - name : Download digests
268+ - name : Download digests for -dist builds
252269 uses : actions/download-artifact@v3
253270 with :
254- name : digests
271+ name : digests-dist
255272 path : /tmp/digests
273+
256274 - name : Set up Docker Buildx
257275 uses : docker/setup-buildx-action@v3
258- - name : Docker meta
276+
277+ - name : Add Docker metadata for image
259278 id : meta_dist
260279 uses : docker/metadata-action@v5
261280 with :
@@ -272,8 +291,8 @@ jobs:
272291 username : ${{ secrets.DOCKER_USERNAME }}
273292 password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
274293
275- - name : Create manifest list and push
276- working-directory : /tmp/digests/dist
294+ - name : Create manifest list from digests and push
295+ working-directory : /tmp/digests
277296 run : |
278297 docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
279298 $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
0 commit comments