Skip to content

Commit d7bf555

Browse files
committed
Optimize workflow
Only push layers to ghcr.io in build job and copy layers from ghcr.io to docker.io if necessary in merge job.
1 parent 2e537e0 commit d7bf555

1 file changed

Lines changed: 3 additions & 33 deletions

File tree

.github/workflows/push.yml

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ jobs:
8888
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
8989
- name: checkout
9090
uses: actions/checkout@v6
91-
- name: Login to docker.io
92-
uses: docker/login-action@v4
93-
with:
94-
registry: docker.io
95-
username: ${{ secrets.DOCKER_USERNAME }}
96-
password: ${{ secrets.DOCKER_PASSWORD }}
9791
- name: Login to ghcr.io
9892
uses: docker/login-action@v4
9993
with:
@@ -106,14 +100,8 @@ jobs:
106100
with:
107101
images: |
108102
${{ env.GHCR_IMAGE }}
109-
${{ github.event_name != 'pull_request' && env.DOCKER_IMAGE || '' }}
110103
tags: |
111104
type=raw,value=${{ needs.get-version.outputs.tag }},enable=true
112-
- name: Extract Docker image name list
113-
id: image-names
114-
run: |
115-
cat ${DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS}
116-
echo "names=$(jq -r '.target["docker-metadata-action"].args.DOCKER_META_IMAGES' ${DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS})" >> ${GITHUB_OUTPUT}
117105
- name: Set up Docker context for Buildx
118106
run: |
119107
docker context create builders
@@ -133,7 +121,7 @@ jobs:
133121
labels: ${{ steps.meta.outputs.labels }}
134122
annotations: ${{ steps.meta.outputs.annotations }}
135123
outputs: |
136-
type=image,"name=${{ steps.image-names.outputs.names }}",push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true
124+
type=image,name=${{ env.GHCR_IMAGE }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true
137125
cache-from: type=gha,scope=${{ github.repository }}-${{ github.ref_name }}-${{ matrix.platform }}
138126
cache-to: type=gha,mode=max,scope=${{ github.repository }}-${{ github.ref_name }}-${{ matrix.platform }}
139127
build-args: |
@@ -206,6 +194,8 @@ jobs:
206194
with:
207195
images: |
208196
${{ env.GHCR_IMAGE }}
197+
${{ env.DOCKER_IMAGE }}
198+
${{ github.event_name != 'pull_request' && env.DOCKER_IMAGE || '' }}
209199
annotations: |
210200
type=org.opencontainers.image.description,value=${{ github.event.repository.description || 'No description provided' }}
211201
tags: |
@@ -223,26 +213,6 @@ jobs:
223213
- name: Inspect ghcr.io image
224214
run: |
225215
docker buildx imagetools inspect '${{ env.GHCR_IMAGE }}:${{ needs.get-version.outputs.tag }}'
226-
227-
- name: Generate Docker metadata for docker.io
228-
uses: docker/metadata-action@v6
229-
with:
230-
images: |
231-
${{ env.DOCKER_IMAGE }}
232-
annotations: |
233-
type=org.opencontainers.image.description,value=${{ github.event.repository.description || 'No description provided' }}
234-
tags: |
235-
type=raw,value=${{ needs.get-version.outputs.tag }},enable=true
236-
- name: Create manifest list and push to docker.io
237-
working-directory: /tmp/digests
238-
run: |
239-
docker buildx imagetools create \
240-
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
241-
--annotation='index:org.opencontainers.image.description=${{ github.event.repository.description }}' \
242-
--annotation='index:org.opencontainers.image.created=${{ steps.timestamp.outputs.timestamp }}' \
243-
--annotation='index:org.opencontainers.image.url=${{ github.event.repository.url }}' \
244-
--annotation='index:org.opencontainers.image.source=${{ github.event.repository.url }}' \
245-
$(printf '${{ env.GHCR_IMAGE }}@sha256:%s ' *)
246216
- name: Inspect docker.io image
247217
run: |
248218
docker buildx imagetools inspect '${{ env.DOCKER_IMAGE }}:${{ needs.get-version.outputs.tag }}'

0 commit comments

Comments
 (0)