124124 push:
125125
126126env:
127- DOCKERHUB_REPO: docker-user/my-app
128- GHCR_REPO: ghcr.io/gh-user/my-app
127+ REGISTRY_IMAGE: user/app
129128
130129jobs:
131130 build:
@@ -146,23 +145,14 @@ jobs:
146145 id: meta
147146 uses: docker/metadata-action@v5
148147 with:
149- images: |
150- ${{ env.DOCKERHUB_REPO }}
151- ${{ env.GHCR_REPO }}
148+ images: ${{ env.REGISTRY_IMAGE }}
152149
153150 - name: Login to Docker Hub
154151 uses: docker/login-action@v3
155152 with:
156153 username: ${{ vars.DOCKERHUB_USERNAME }}
157154 password: ${{ secrets.DOCKERHUB_TOKEN }}
158155
159- - name: Login to GHCR
160- uses: docker/login-action@v3
161- with:
162- registry: ghcr.io
163- username: ${{ github.repository_owner }}
164- password: ${{ secrets.GITHUB_TOKEN }}
165-
166156 - name: Set up QEMU
167157 uses: docker/setup-qemu-action@v3
168158
@@ -175,7 +165,8 @@ jobs:
175165 with:
176166 platforms: ${{ matrix.platform }}
177167 labels: ${{ steps.meta.outputs.labels }}
178- outputs: type=image,"name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
168+ tags: ${{ env.REGISTRY_IMAGE }}
169+ outputs: type=image,push-by-digest=true,name-canonical=true,push=true
179170
180171 - name: Export digest
181172 run: |
@@ -209,23 +200,14 @@ jobs:
209200 username: ${{ vars.DOCKERHUB_USERNAME }}
210201 password: ${{ secrets.DOCKERHUB_TOKEN }}
211202
212- - name: Login to GHCR
213- uses: docker/login-action@v3
214- with:
215- registry: ghcr.io
216- username: ${{ github.repository_owner }}
217- password: ${{ secrets.GITHUB_TOKEN }}
218-
219203 - name: Set up Docker Buildx
220204 uses: docker/setup-buildx-action@v3
221205
222206 - name: Docker meta
223207 id: meta
224208 uses: docker/metadata-action@v5
225209 with:
226- images: |
227- ${{ env.DOCKERHUB_REPO }}
228- ${{ env.GHCR_REPO }}
210+ images: ${{ env.REGISTRY_IMAGE }}
229211 tags: |
230212 type=ref,event=branch
231213 type=ref,event=pr
@@ -236,14 +218,11 @@ jobs:
236218 working-directory: ${{ runner.temp }}/digests
237219 run: |
238220 docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
239- $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *)
240- docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
241- $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *)
221+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
242222
243223 - name: Inspect image
244224 run: |
245- docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:${{ steps.meta.outputs.version }}
246- docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
225+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
247226` ` `
248227
249228# ## With Bake
@@ -377,9 +356,9 @@ jobs:
377356 cwd://${{ runner.temp }}/bake-meta.json
378357 targets: image
379358 set: |
380- *.tags=
359+ *.tags=${{ env.REGISTRY_IMAGE }}
381360 *.platform=${{ matrix.platform }}
382- *.output=type=image,"name=${{ env.REGISTRY_IMAGE }}", push-by-digest=true,name-canonical=true,push=true
361+ *.output=type=image,push-by-digest=true,name-canonical=true,push=true
383362
384363 - name: Export digest
385364 run: |
0 commit comments