Skip to content

Commit e5c3e71

Browse files
committed
Refactor Docker manifest creation in GitHub Actions workflow
- Updated manifest creation to use Docker CLI commands for improved reliability and clarity. - Added removal of existing manifests before creation to prevent conflicts. - Enhanced multi-architecture support by pushing manifests for both latest and version-specific tags.
1 parent 2621a03 commit e5c3e71

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

.github/workflows/docker-publish.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,36 @@ jobs:
131131
132132
# For main branch or latest tag
133133
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
134-
# Create a manifest directly without pulling
135-
docker buildx imagetools create --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
134+
# Create a manifest using docker CLI commands
135+
docker manifest rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest || true
136+
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
136137
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
137138
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
139+
140+
# Push the manifest
141+
docker manifest push --purge ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
138142
fi
139143
140144
# For tags (releases)
141145
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
142146
VERSION=${GITHUB_REF#refs/tags/v}
143147
144148
# Create version tag manifest
145-
docker buildx imagetools create --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \
149+
docker manifest rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} || true
150+
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \
146151
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \
147152
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-arm64
148153
154+
# Push the manifest
155+
docker manifest push --purge ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}
156+
149157
# Create major.minor tag manifest
150158
MAJOR_MINOR=$(echo ${VERSION} | cut -d. -f1,2)
151-
docker buildx imagetools create --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MAJOR_MINOR} \
159+
docker manifest rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MAJOR_MINOR} || true
160+
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MAJOR_MINOR} \
152161
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION} \
153162
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}-arm64
163+
164+
# Push the manifest
165+
docker manifest push --purge ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${MAJOR_MINOR}
154166
fi

0 commit comments

Comments
 (0)