@@ -3,10 +3,10 @@ name: Publish Docker Image
33on :
44 push :
55 tags :
6- - ' *'
6+ - ' *'
77
88jobs :
9- build-and-push-image :
9+ build :
1010 strategy :
1111 matrix :
1212 include :
@@ -49,11 +49,67 @@ jobs:
4949 openhv/server
5050 ghcr.io/${{ github.repository }}
5151
52- - name : Build and push Docker image
52+ - name : Build and push platform image
5353 uses : docker/build-push-action@v6
5454 with :
5555 context : .
5656 platforms : ${{ matrix.platform }}
5757 push : true
58- tags : ${{ steps.meta.outputs.tags }}
58+ tags : ${{ steps.meta.outputs.tags }}-${{ matrix.arch }}
5959 labels : ${{ steps.meta.outputs.labels }}
60+
61+ - name : Upload image digest
62+ run : |
63+ mkdir -p digests
64+ docker buildx imagetools inspect ${{ steps.meta.outputs.tags }}-${{ matrix.arch }} --format '{{json .}}' > digests/${{ matrix.arch }}.json
65+ if : always()
66+ - name : Upload digest artifact
67+ uses : actions/upload-artifact@v4
68+ with :
69+ name : digest-${{ matrix.arch }}
70+ path : digests/${{ matrix.arch }}.json
71+
72+ manifest :
73+ needs : build
74+ runs-on : ubuntu-24.04
75+ permissions :
76+ contents : read
77+ packages : write
78+
79+ steps :
80+ - name : Download digest artifacts
81+ uses : actions/download-artifact@v4
82+ with :
83+ path : digests
84+ - name : Set up Docker Buildx
85+ uses : docker/setup-buildx-action@v3
86+
87+ - name : Log in to Docker Hub
88+ uses : docker/login-action@v3
89+ with :
90+ username : ${{ secrets.DOCKER_USERNAME }}
91+ password : ${{ secrets.DOCKER_PASSWORD }}
92+
93+ - name : Log in to the Container registry
94+ uses : docker/login-action@v3
95+ with :
96+ registry : ghcr.io
97+ username : ${{ github.actor }}
98+ password : ${{ secrets.GITHUB_TOKEN }}
99+
100+ - name : Extract tags and labels for Docker
101+ id : meta
102+ uses : docker/metadata-action@v5
103+ with :
104+ images : |
105+ openhv/server
106+ ghcr.io/${{ github.repository }}
107+
108+ - name : Create and push multi-arch manifest
109+ run : |
110+ for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
111+ docker buildx imagetools create \
112+ -t "$tag" \
113+ "$tag-amd64" \
114+ "$tag-arm64"
115+ done
0 commit comments