124
124
push:
125
125
126
126
env:
127
- DOCKERHUB_REPO: docker-user/my-app
128
- GHCR_REPO: ghcr.io/gh-user/my-app
127
+ REGISTRY_IMAGE: user/app
129
128
130
129
jobs:
131
130
build:
@@ -146,23 +145,14 @@ jobs:
146
145
id: meta
147
146
uses: docker/metadata-action@v5
148
147
with:
149
- images: |
150
- ${{ env.DOCKERHUB_REPO }}
151
- ${{ env.GHCR_REPO }}
148
+ images: ${{ env.REGISTRY_IMAGE }}
152
149
153
150
- name: Login to Docker Hub
154
151
uses: docker/login-action@v3
155
152
with:
156
153
username: ${{ vars.DOCKERHUB_USERNAME }}
157
154
password: ${{ secrets.DOCKERHUB_TOKEN }}
158
155
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
-
166
156
- name: Set up QEMU
167
157
uses: docker/setup-qemu-action@v3
168
158
@@ -175,7 +165,8 @@ jobs:
175
165
with:
176
166
platforms: ${{ matrix.platform }}
177
167
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
179
170
180
171
- name: Export digest
181
172
run: |
@@ -209,23 +200,14 @@ jobs:
209
200
username: ${{ vars.DOCKERHUB_USERNAME }}
210
201
password: ${{ secrets.DOCKERHUB_TOKEN }}
211
202
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
-
219
203
- name: Set up Docker Buildx
220
204
uses: docker/setup-buildx-action@v3
221
205
222
206
- name: Docker meta
223
207
id: meta
224
208
uses: docker/metadata-action@v5
225
209
with:
226
- images: |
227
- ${{ env.DOCKERHUB_REPO }}
228
- ${{ env.GHCR_REPO }}
210
+ images: ${{ env.REGISTRY_IMAGE }}
229
211
tags: |
230
212
type=ref,event=branch
231
213
type=ref,event=pr
@@ -236,14 +218,11 @@ jobs:
236
218
working-directory: ${{ runner.temp }}/digests
237
219
run: |
238
220
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 ' *)
242
222
243
223
- name: Inspect image
244
224
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 }}
247
226
` ` `
248
227
249
228
# ## With Bake
@@ -377,9 +356,9 @@ jobs:
377
356
cwd://${{ runner.temp }}/bake-meta.json
378
357
targets: image
379
358
set: |
380
- *.tags=
359
+ *.tags=${{ env.REGISTRY_IMAGE }}
381
360
*.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
383
362
384
363
- name: Export digest
385
364
run: |
0 commit comments