10
10
- ' [2-9][0-9].[0-1][0-9].?[0-3]?[0-9]?'
11
11
12
12
env :
13
- REGISTRY_IMAGE : erhhung/al2023-devops
13
+ IMAGE_NAME : erhhung/al2023-devops
14
14
IMAGE_LABELS : |
15
15
org.opencontainers.image.authors=Erhhung Yuan <[email protected] >
16
16
@@ -124,7 +124,9 @@ jobs:
124
124
id : metadata
125
125
uses : docker/metadata-action@v5
126
126
with :
127
- images : ${{ env.REGISTRY_IMAGE }}
127
+ images : |
128
+ docker.io/${{ env.IMAGE_NAME }}
129
+ ghcr.io/${{ env.IMAGE_NAME }}
128
130
labels : ${{ env.IMAGE_LABELS }}
129
131
130
132
# https://github.com/aws-actions/configure-aws-credentials
@@ -148,9 +150,19 @@ jobs:
148
150
id : docker-hub
149
151
uses : docker/login-action@v3
150
152
with :
153
+ registry : docker.io
151
154
username : ${{ secrets.DOCKER_HUB_USERNAME }}
152
155
password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
153
156
157
+ # https://github.com/docker/login-action
158
+ - name : Log in to GitHub GHCR
159
+ id : ghcr
160
+ uses : docker/login-action@v3
161
+ with :
162
+ registry : ghcr.io
163
+ username : ${{ github.actor }}
164
+ password : ${{ github.token }}
165
+
154
166
# https://github.com/docker/build-push-action
155
167
- name : Build and Push by Digest
156
168
id : build
@@ -160,7 +172,7 @@ jobs:
160
172
with :
161
173
platforms : ${{ matrix.platform }}
162
174
labels : ${{ steps.metadata.outputs.labels }}
163
- outputs : type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
175
+ outputs : type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
164
176
165
177
# create 0-byte file named /tmp/digests/<digest>
166
178
- name : Export Digest
@@ -209,30 +221,42 @@ jobs:
209
221
id : metadata
210
222
uses : docker/metadata-action@v5
211
223
with :
212
- images : ${{ env.REGISTRY_IMAGE }}
224
+ images : |
225
+ docker.io/${{ env.IMAGE_NAME }}
226
+ ghcr.io/${{ env.IMAGE_NAME }}
213
227
labels : ${{ env.IMAGE_LABELS }}
214
228
215
229
# https://github.com/docker/login-action
216
230
- name : Log in to Docker Hub
217
231
id : docker-hub
218
232
uses : docker/login-action@v3
219
233
with :
234
+ registry : docker.io
220
235
username : ${{ secrets.DOCKER_HUB_USERNAME }}
221
236
password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
222
237
238
+ # https://github.com/docker/login-action
239
+ - name : Log in to GitHub GHCR
240
+ id : ghcr
241
+ uses : docker/login-action@v3
242
+ with :
243
+ registry : ghcr.io
244
+ username : ${{ github.actor }}
245
+ password : ${{ github.token }}
246
+
223
247
- name : Create Manifests and Push
224
248
id : manifests
225
249
working-directory : /tmp/digests
226
250
run : |
227
251
tags=($(jq -cr '[.tags[] | "-t \(.)"] | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON"))
228
- images=($(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *))
252
+ images=($(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *))
229
253
docker buildx imagetools create "${tags[@]}" "${images[@]}"
230
254
231
255
# confirm merged image manifests
232
256
- name : Inspect Image
233
257
id : inspect
234
258
run : |
235
- tag="${{ env.REGISTRY_IMAGE }}:$DOCKER_METADATA_OUTPUT_VERSION"
259
+ tag="${{ env.IMAGE_NAME }}:$DOCKER_METADATA_OUTPUT_VERSION"
236
260
docker buildx imagetools inspect $tag
237
261
238
262
terminate-runner :
0 commit comments