Skip to content

Commit 131319a

Browse files
committed
Merge platforms before publishing.
1 parent 9ca84dc commit 131319a

File tree

1 file changed

+64
-5
lines changed

1 file changed

+64
-5
lines changed

.github/workflows/docker.yml

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- '*'
77

88
jobs:
9-
build-and-push-image:
9+
build:
1010
strategy:
1111
matrix:
1212
include:
@@ -48,12 +48,71 @@ jobs:
4848
images: |
4949
openhv/server
5050
ghcr.io/${{ github.repository }}
51+
tags: |
52+
type=ref,event=tag
53+
type=raw,value=${{ github.ref_name }}
5154
52-
- name: Build and push Docker image
55+
56+
- name: Build image by digest
57+
id: build
5358
uses: docker/build-push-action@v6
5459
with:
55-
context: .
5660
platforms: ${{ matrix.platform }}
57-
push: true
58-
tags: ${{ steps.meta.outputs.tags }}
5961
labels: ${{ steps.meta.outputs.labels }}
62+
tags: ${{ steps.meta.outputs.tags }}
63+
outputs: type=image,name-canonical=true
64+
65+
- name: Export digest
66+
run: |
67+
mkdir -p ${{ runner.temp }}/digests
68+
digest="${{ steps.build.outputs.digest }}"
69+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
70+
71+
- name: Upload digest
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: digests-${{ matrix.arch }}
75+
path: ${{ runner.temp }}/digests/*
76+
if-no-files-found: error
77+
retention-days: 1
78+
79+
80+
merge:
81+
runs-on: ubuntu-latest
82+
needs:
83+
- build
84+
steps:
85+
- name: Download digests
86+
uses: actions/download-artifact@v4
87+
with:
88+
path: ${{ runner.temp }}/digests
89+
pattern: digests-*
90+
merge-multiple: true
91+
92+
- name: Log in to Docker Hub
93+
uses: docker/login-action@v3
94+
with:
95+
username: ${{ secrets.DOCKER_USERNAME }}
96+
password: ${{ secrets.DOCKER_PASSWORD }}
97+
98+
- name: Set up Docker Buildx
99+
uses: docker/setup-buildx-action@v3
100+
101+
- name: Docker meta
102+
id: meta
103+
uses: docker/metadata-action@v5
104+
with:
105+
images: ${{ env.REGISTRY_IMAGE }}
106+
tags: |
107+
type=ref,event=tag
108+
type=raw,value=${{ github.ref_name }}
109+
110+
- name: Create manifest list and push
111+
working-directory: ${{ runner.temp }}/digests
112+
run: |
113+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
114+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
115+
116+
- name: Inspect image
117+
run: |
118+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)