Skip to content

Commit 12518b4

Browse files
dpark01claude
andcommitted
Address review: sanitize branch names, audit major.minor tags
- Apply same tag sanitization as docker.yml (replace / with -, strip leading v) in cleanup workflow, matching deploy-to-quay tag format - Audit workflow now also checks X.Y-flavor tags (e.g., 3.0-baseimage) since those were affected in the incident too Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 948dbe8 commit 12518b4

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

.github/workflows/audit-quay-tags.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,27 @@ jobs:
3838
exit 1
3939
fi
4040
41-
for VERSION in $VERSIONS; do
42-
# Check mega tag (no suffix)
43-
if ! crane manifest "${REPO}:${VERSION}" > /dev/null 2>&1; then
44-
echo "::error::MISSING: ${REPO}:${VERSION}"
41+
check_tag() {
42+
local TAG="$1"
43+
if ! crane manifest "${REPO}:${TAG}" > /dev/null 2>&1; then
44+
echo "::error::MISSING: ${REPO}:${TAG}"
4545
FAILED=1
4646
else
47-
echo "OK: ${REPO}:${VERSION}"
47+
echo "OK: ${REPO}:${TAG}"
4848
fi
49+
}
50+
51+
for VERSION in $VERSIONS; do
52+
MAJOR_MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
53+
54+
# Check mega tag (no suffix) — both X.Y.Z and X.Y
55+
check_tag "${VERSION}"
56+
check_tag "${MAJOR_MINOR}"
4957
50-
# Check each flavor
58+
# Check each flavor — both X.Y.Z-flavor and X.Y-flavor
5159
for FLAVOR in $FLAVORS; do
52-
TAG="${VERSION}-${FLAVOR}"
53-
if ! crane manifest "${REPO}:${TAG}" > /dev/null 2>&1; then
54-
echo "::error::MISSING: ${REPO}:${TAG}"
55-
FAILED=1
56-
else
57-
echo "OK: ${REPO}:${TAG}"
58-
fi
60+
check_tag "${VERSION}-${FLAVOR}"
61+
check_tag "${MAJOR_MINOR}-${FLAVOR}"
5962
done
6063
done
6164

.github/workflows/cleanup-images.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,22 @@ jobs:
1111
permissions: {}
1212

1313
steps:
14+
- name: Compute tag prefix
15+
id: tag-prefix
16+
run: |
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})"
24+
1425
- name: Safety check - refuse version-like branch names
1526
run: |
16-
BRANCH_TAG="${{ github.event.ref }}"
17-
if [[ "$BRANCH_TAG" =~ ^v?[0-9]+\.[0-9]+ ]]; then
18-
echo "::error::Refusing to delete tags for version-like branch: $BRANCH_TAG"
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"
1930
exit 1
2031
fi
2132
@@ -31,15 +42,15 @@ jobs:
3142

3243
- name: Delete feature branch tags from Quay
3344
run: |
34-
BRANCH_TAG="${{ github.event.ref }}"
45+
TAG_PREFIX="${{ steps.tag-prefix.outputs.prefix }}"
3546
QUAY_REPO="quay.io/broadinstitute/viral-ngs"
3647
3748
# Image tag suffixes - must be kept in sync with deploy-to-quay in docker.yml
3849
# See: .github/workflows/docker.yml deploy-to-quay job matrix
3950
SUFFIXES=("-baseimage" "-core" "-assemble" "-classify" "-phylo" "")
4051
4152
for SUFFIX in "${SUFFIXES[@]}"; do
42-
TAG="${BRANCH_TAG}${SUFFIX}"
53+
TAG="${TAG_PREFIX}${SUFFIX}"
4354
echo "Deleting ${QUAY_REPO}:${TAG}..."
4455
# Use crane delete instead of skopeo delete. crane removes only the tag
4556
# reference, not the underlying manifest. This prevents cascade deletion

0 commit comments

Comments
 (0)