3737 uses : docker/metadata-action@v5
3838 with :
3939 images : ${{ env.IMAGE_NAME }}
40+ tags : |
41+ type=ref,event=branch
42+ type=semver,pattern={{version}}
43+ type=semver,pattern={{major}}.{{minor}}
44+
4045 - uses : actions/checkout@v3
4146 - name : Login to ghcr
4247 uses : docker/login-action@v3
@@ -58,17 +63,66 @@ jobs:
5863 context : .
5964 file : Dockerfile
6065 outputs : type=docker
66+ labels : ${{ steps.meta.outputs.labels }}
6167 platforms : ${{ matrix.platform }}
62- push : ${{ github.event_name == 'push' }}
63- tags : |
64- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.sync_version }}
65- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
68+ tags : ${{ steps.meta.outputs.tags }}
69+ - name : Export digest
70+ run : |
71+ mkdir -p ${{ runner.temp }}/digests
72+ digest="${{ steps.build.outputs.digest }}"
73+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
74+ - name : Upload digest
75+ uses : actions/upload-artifact@v4
76+ with :
77+ name : digests-${{ env.PLATFORM_PAIR }}
78+ path : ${{ runner.temp }}/digests/*
79+ if-no-files-found : error
80+ retention-days : 1
6681 - name : Attest
6782 uses : actions/attest-build-provenance@v2
6883 if : ${{ github.event_name == 'push' }}
6984 with :
7085 subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
7186 subject-digest : ${{ steps.build.outputs.digest }}
7287 push-to-registry : true
88+ merge :
89+ runs-on : ubuntu-24.04
90+ needs :
91+ - build
92+ steps :
93+ - name : Download digests
94+ uses : actions/download-artifact@v4
95+ with :
96+ path : ${{ runner.temp }}/digests
97+ pattern : digests-*
98+ merge-multiple : true
99+
100+ - name : Login to Docker Hub
101+ uses : docker/login-action@v3
102+ with :
103+ username : ${{ vars.DOCKERHUB_USERNAME }}
104+ password : ${{ secrets.DOCKERHUB_TOKEN }}
105+
106+ - name : Set up Docker Buildx
107+ uses : docker/setup-buildx-action@v3
73108
74-
109+ - name : Docker meta
110+ id : meta
111+ uses : docker/metadata-action@v5
112+ with :
113+ images : ${{ env.IMAGE_NAME }}
114+ tags : |
115+ type=ref,event=branch
116+ type=ref,event=pr
117+ type=semver,pattern={{version}}
118+ type=semver,pattern={{major}}.{{minor}}
119+
120+ - name : Create manifest list and push
121+ working-directory : ${{ runner.temp }}/digests
122+ run : |
123+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
124+ $(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
125+
126+ - name : Inspect image
127+ run : |
128+ docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
0 commit comments