@@ -11,28 +11,51 @@ jobs:
1111 permissions : {}
1212
1313 steps :
14- - name : Delete feature branch images from Quay
14+ - name : Compute tag prefix
15+ id : tag-prefix
1516 run : |
16- # Install skopeo
17- sudo apt-get update && sudo apt-get install -y skopeo
17+ # Apply the same sanitization as docker.yml's "Compute Docker image tag prefix":
18+ # replace "/" with "-" and strip leading "v"
19+ RAW="${{ github.event.ref }}"
20+ PREFIX=$(echo "$RAW" | sed 's|/|-|g')
21+ PREFIX=${PREFIX#v}
22+ echo "prefix=${PREFIX}" >> $GITHUB_OUTPUT
23+ echo "Tag prefix: ${PREFIX} (from branch: ${RAW})"
1824
19- BRANCH_TAG="${{ github.event.ref }}"
25+ - name : Safety check - refuse version-like branch names
26+ run : |
27+ PREFIX="${{ steps.tag-prefix.outputs.prefix }}"
28+ if [[ "$PREFIX" =~ ^[0-9]+\.[0-9]+ ]]; then
29+ echo "::error::Refusing to delete tags for version-like branch: $PREFIX"
30+ exit 1
31+ fi
32+
33+ - name : Install crane
34+ uses : imjasonh/setup-crane@v0.4
35+
36+ - name : Log in to Quay.io
37+ uses : docker/login-action@v3
38+ with :
39+ registry : quay.io
40+ username : ${{ secrets.QUAY_USERNAME }}
41+ password : ${{ secrets.QUAY_TOKEN }}
42+
43+ - name : Delete feature branch tags from Quay
44+ run : |
45+ TAG_PREFIX="${{ steps.tag-prefix.outputs.prefix }}"
2046 QUAY_REPO="quay.io/broadinstitute/viral-ngs"
2147
22- # Image tags to delete - must be kept in sync with deploy-to-quay in docker.yml
48+ # Image tag suffixes - must be kept in sync with deploy-to-quay in docker.yml
2349 # See: .github/workflows/docker.yml deploy-to-quay job matrix
24- IMAGES=(
25- "${BRANCH_TAG}-baseimage"
26- "${BRANCH_TAG}-core"
27- "${BRANCH_TAG}-assemble"
28- "${BRANCH_TAG}-classify"
29- "${BRANCH_TAG}-phylo"
30- "${BRANCH_TAG}" # mega image (no suffix)
31- )
32-
33- for TAG in "${IMAGES[@]}"; do
50+ SUFFIXES=("-baseimage" "-core" "-assemble" "-classify" "-phylo" "")
51+
52+ for SUFFIX in "${SUFFIXES[@]}"; do
53+ TAG="${TAG_PREFIX}${SUFFIX}"
3454 echo "Deleting ${QUAY_REPO}:${TAG}..."
35- skopeo delete \
36- --creds "${{ secrets.QUAY_USERNAME }}:${{ secrets.QUAY_TOKEN }}" \
37- "docker://${QUAY_REPO}:${TAG}" || echo "Tag ${TAG} not found or already deleted"
55+ # Use crane delete instead of skopeo delete. crane removes only the tag
56+ # reference, not the underlying manifest. This prevents cascade deletion
57+ # of other tags sharing the same digest (which caused the 3.0.10-baseimage
58+ # incident: skopeo deleted the manifest by digest, expiring all tags
59+ # pointing to it).
60+ crane delete "${QUAY_REPO}:${TAG}" 2>&1 || echo " Tag ${TAG} not found or already deleted"
3861 done
0 commit comments