Skip to content

Commit 3d8bba8

Browse files
committed
ci(release): publish docker digests to both registries
1 parent e05eec5 commit 3d8bba8

1 file changed

Lines changed: 46 additions & 14 deletions

File tree

.github/workflows/release.yaml

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,19 @@ jobs:
195195
username: ${{ github.actor }}
196196
password: ${{ secrets.GITHUB_TOKEN }}
197197

198+
- name: Log in to Docker Hub
199+
uses: docker/login-action@v3
200+
with:
201+
username: ${{ secrets.DOCKERHUB_USERNAME }}
202+
password: ${{ secrets.DOCKERHUB_TOKEN }}
203+
198204
- name: Build and push by digest
199205
id: build
200206
uses: docker/build-push-action@v6
201207
with:
202208
context: .
203209
platforms: ${{ matrix.platform }}
204-
outputs: type=image,name=${{ env.GHCR_IMAGE }},push-by-digest=true,name-canonical=true,push=true
210+
outputs: type=image,"name=${{ env.GHCR_IMAGE }},${{ env.DOCKERHUB_IMAGE }}",push-by-digest=true,name-canonical=true,push=true
205211
build-args: |
206212
ENABLE_OTEL=false
207213
ENABLE_EMBEDUI=${{ matrix.enable_embedui }}
@@ -280,18 +286,28 @@ jobs:
280286
- name: Create manifest list and push
281287
working-directory: /tmp/digests
282288
run: |
283-
# Compose -t flags from metadata-action tags (newline-separated)
284-
TAG_ARGS=()
289+
# Compose -t flags from metadata-action tags (newline-separated).
290+
GHCR_IMAGE="${{ env.GHCR_IMAGE }}"
291+
DOCKERHUB_IMAGE="${{ env.DOCKERHUB_IMAGE }}"
292+
GHCR_TAG_ARGS=()
293+
DOCKERHUB_TAG_ARGS=()
285294
while IFS= read -r tag; do
286-
[ -n "$tag" ] && TAG_ARGS+=("-t" "$tag")
295+
if [[ "$tag" == "$GHCR_IMAGE:"* ]]; then
296+
GHCR_TAG_ARGS+=("-t" "$tag")
297+
elif [[ "$tag" == "$DOCKERHUB_IMAGE:"* ]]; then
298+
DOCKERHUB_TAG_ARGS+=("-t" "$tag")
299+
fi
287300
done <<< "${{ steps.meta.outputs.tags }}"
288-
# Compose source digest refs (pushed to GHCR by docker-build)
289-
DIGEST_ARGS=()
301+
# Compose source digest refs pushed to each registry by docker-build.
302+
GHCR_DIGEST_ARGS=()
303+
DOCKERHUB_DIGEST_ARGS=()
290304
for f in *; do
291-
DIGEST_ARGS+=("${{ env.GHCR_IMAGE }}@sha256:$f")
305+
GHCR_DIGEST_ARGS+=("$GHCR_IMAGE@sha256:$f")
306+
DOCKERHUB_DIGEST_ARGS+=("$DOCKERHUB_IMAGE@sha256:$f")
292307
done
293308
set -x
294-
docker buildx imagetools create "${TAG_ARGS[@]}" "${DIGEST_ARGS[@]}"
309+
docker buildx imagetools create "${GHCR_TAG_ARGS[@]}" "${GHCR_DIGEST_ARGS[@]}"
310+
docker buildx imagetools create "${DOCKERHUB_TAG_ARGS[@]}" "${DOCKERHUB_DIGEST_ARGS[@]}"
295311
296312
- name: Inspect manifest
297313
run: |
@@ -327,13 +343,19 @@ jobs:
327343
username: ${{ github.actor }}
328344
password: ${{ secrets.GITHUB_TOKEN }}
329345

346+
- name: Log in to Docker Hub
347+
uses: docker/login-action@v3
348+
with:
349+
username: ${{ secrets.DOCKERHUB_USERNAME }}
350+
password: ${{ secrets.DOCKERHUB_TOKEN }}
351+
330352
- name: Build and push by digest
331353
id: build
332354
uses: docker/build-push-action@v6
333355
with:
334356
context: ui/web
335357
platforms: ${{ matrix.platform }}
336-
outputs: type=image,name=${{ env.GHCR_IMAGE }}-web,push-by-digest=true,name-canonical=true,push=true
358+
outputs: type=image,"name=${{ env.GHCR_IMAGE }}-web,${{ env.DOCKERHUB_IMAGE }}-web",push-by-digest=true,name-canonical=true,push=true
337359
cache-from: type=gha,scope=web-${{ matrix.arch }}
338360
cache-to: type=gha,mode=max,scope=web-${{ matrix.arch }}
339361
provenance: false
@@ -393,16 +415,26 @@ jobs:
393415
- name: Create manifest list and push
394416
working-directory: /tmp/digests
395417
run: |
396-
TAG_ARGS=()
418+
GHCR_IMAGE="${{ env.GHCR_IMAGE }}-web"
419+
DOCKERHUB_IMAGE="${{ env.DOCKERHUB_IMAGE }}-web"
420+
GHCR_TAG_ARGS=()
421+
DOCKERHUB_TAG_ARGS=()
397422
while IFS= read -r tag; do
398-
[ -n "$tag" ] && TAG_ARGS+=("-t" "$tag")
423+
if [[ "$tag" == "$GHCR_IMAGE:"* ]]; then
424+
GHCR_TAG_ARGS+=("-t" "$tag")
425+
elif [[ "$tag" == "$DOCKERHUB_IMAGE:"* ]]; then
426+
DOCKERHUB_TAG_ARGS+=("-t" "$tag")
427+
fi
399428
done <<< "${{ steps.meta.outputs.tags }}"
400-
DIGEST_ARGS=()
429+
GHCR_DIGEST_ARGS=()
430+
DOCKERHUB_DIGEST_ARGS=()
401431
for f in *; do
402-
DIGEST_ARGS+=("${{ env.GHCR_IMAGE }}-web@sha256:$f")
432+
GHCR_DIGEST_ARGS+=("$GHCR_IMAGE@sha256:$f")
433+
DOCKERHUB_DIGEST_ARGS+=("$DOCKERHUB_IMAGE@sha256:$f")
403434
done
404435
set -x
405-
docker buildx imagetools create "${TAG_ARGS[@]}" "${DIGEST_ARGS[@]}"
436+
docker buildx imagetools create "${GHCR_TAG_ARGS[@]}" "${GHCR_DIGEST_ARGS[@]}"
437+
docker buildx imagetools create "${DOCKERHUB_TAG_ARGS[@]}" "${DOCKERHUB_DIGEST_ARGS[@]}"
406438
407439
- name: Inspect manifest
408440
run: |

0 commit comments

Comments
 (0)