Skip to content

Commit ec76930

Browse files
committed
Refactor Docker image tagging and manifest creation in GitHub Actions workflow
- Updated Docker image tags to use 'latest-amd64' and 'latest-arm64' for better clarity. - Replaced traditional manifest creation commands with `docker buildx imagetools create` for improved efficiency. - Streamlined the process for creating version-specific and major.minor tag manifests without pulling images.
1 parent cf3d361 commit ec76930

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

.github/workflows/docker-publish.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
with:
3838
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3939
tags: |
40-
type=raw,value=amd64,enable={{is_default_branch}}
40+
type=raw,value=latest-amd64,enable={{is_default_branch}}
4141
type=ref,event=branch,suffix=-amd64
4242
type=ref,event=pr,suffix=-amd64
4343
type=semver,pattern={{version}}-amd64
@@ -82,7 +82,7 @@ jobs:
8282
with:
8383
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
8484
tags: |
85-
type=raw,value=arm64,enable={{is_default_branch}}
85+
type=raw,value=latest-arm64,enable={{is_default_branch}}
8686
type=ref,event=branch,suffix=-arm64
8787
type=ref,event=pr,suffix=-arm64
8888
type=semver,pattern={{version}}-arm64
@@ -131,33 +131,24 @@ jobs:
131131
132132
# For main branch or latest tag
133133
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
134-
# Create a manifest for latest
135-
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
136-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64 \
137-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64
138-
139-
# Push the manifest
140-
docker manifest push --purge ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
134+
# Create a manifest directly without pulling
135+
docker buildx imagetools create --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
136+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \
137+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
141138
fi
142139
143140
# For tags (releases)
144141
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
145142
VERSION=${GITHUB_REF#refs/tags/v}
146143
147144
# Create version tag manifest
148-
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \
145+
docker buildx imagetools create --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \
149146
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-amd64 \
150147
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-arm64
151148
152-
# Push the manifest
153-
docker manifest push --purge ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}
154-
155149
# Create major.minor tag manifest
156150
MAJOR_MINOR=$(echo ${VERSION} | cut -d. -f1,2)
157-
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MAJOR_MINOR} \
151+
docker buildx imagetools create --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MAJOR_MINOR} \
158152
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-amd64 \
159153
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-arm64
160-
161-
# Push the manifest
162-
docker manifest push --purge ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MAJOR_MINOR}
163154
fi

0 commit comments

Comments
 (0)