Skip to content

Commit 52542de

Browse files
authored
Merge pull request #1029 from broadinstitute/cleanup-branch-images
Delete feature branch images from Quay on branch deletion
2 parents c5aaec2 + 4d52c8f commit 52542de

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Cleanup Feature Branch Images
2+
3+
on:
4+
delete:
5+
6+
jobs:
7+
cleanup-quay-images:
8+
# Only run for branch deletions (not tags), and skip main
9+
if: github.event.ref_type == 'branch' && github.event.ref != 'main'
10+
runs-on: ubuntu-latest
11+
permissions: {}
12+
13+
steps:
14+
- name: Delete feature branch images from Quay
15+
run: |
16+
# Install skopeo
17+
sudo apt-get update && sudo apt-get install -y skopeo
18+
19+
BRANCH_TAG="${{ github.event.ref }}"
20+
QUAY_REPO="quay.io/broadinstitute/viral-ngs"
21+
22+
# Image tags to delete - must be kept in sync with deploy-to-quay in docker.yml
23+
# 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
34+
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"
38+
done

.github/workflows/docker.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ jobs:
165165
platforms: linux/amd64
166166
push: true
167167
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-baseimage-amd64
168-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
169168
cache-from: |
170169
type=registry,ref=${{ env.GHCR_REPO }}:cache-baseimage-amd64-${{ needs.get-version.outputs.image-tag-prefix }}
171170
type=registry,ref=${{ env.GHCR_REPO }}:cache-baseimage-amd64-main
@@ -204,7 +203,6 @@ jobs:
204203
platforms: linux/arm64
205204
push: true
206205
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-baseimage-arm64
207-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
208206
cache-from: |
209207
type=registry,ref=${{ env.GHCR_REPO }}:cache-baseimage-arm64-${{ needs.get-version.outputs.image-tag-prefix }}
210208
type=registry,ref=${{ env.GHCR_REPO }}:cache-baseimage-arm64-main
@@ -319,7 +317,6 @@ jobs:
319317
platforms: linux/amd64
320318
push: true
321319
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-amd64
322-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
323320
build-args: |
324321
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-baseimage-amd64
325322
VERSION=${{ needs.get-version.outputs.version }}
@@ -363,7 +360,6 @@ jobs:
363360
platforms: linux/arm64
364361
push: true
365362
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-arm64
366-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
367363
build-args: |
368364
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-baseimage-arm64
369365
VERSION=${{ needs.get-version.outputs.version }}
@@ -480,7 +476,6 @@ jobs:
480476
platforms: linux/amd64
481477
push: true
482478
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-assemble-amd64
483-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
484479
build-args: |
485480
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-amd64
486481
VERSION=${{ needs.get-version.outputs.version }}
@@ -524,7 +519,6 @@ jobs:
524519
platforms: linux/arm64
525520
push: true
526521
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-assemble-arm64
527-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
528522
build-args: |
529523
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-arm64
530524
VERSION=${{ needs.get-version.outputs.version }}
@@ -641,7 +635,6 @@ jobs:
641635
platforms: linux/amd64
642636
push: true
643637
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-classify-amd64
644-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
645638
build-args: |
646639
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-amd64
647640
VERSION=${{ needs.get-version.outputs.version }}
@@ -685,7 +678,6 @@ jobs:
685678
platforms: linux/arm64
686679
push: true
687680
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-classify-arm64
688-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
689681
build-args: |
690682
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-arm64
691683
VERSION=${{ needs.get-version.outputs.version }}
@@ -802,7 +794,6 @@ jobs:
802794
platforms: linux/amd64
803795
push: true
804796
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-phylo-amd64
805-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
806797
build-args: |
807798
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-amd64
808799
VERSION=${{ needs.get-version.outputs.version }}
@@ -846,7 +837,6 @@ jobs:
846837
platforms: linux/arm64
847838
push: true
848839
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-phylo-arm64
849-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
850840
build-args: |
851841
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-arm64
852842
VERSION=${{ needs.get-version.outputs.version }}
@@ -963,7 +953,6 @@ jobs:
963953
platforms: linux/amd64
964954
push: true
965955
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-mega-amd64
966-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
967956
build-args: |
968957
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-amd64
969958
VERSION=${{ needs.get-version.outputs.version }}
@@ -1007,7 +996,6 @@ jobs:
1007996
platforms: linux/arm64
1008997
push: true
1009998
tags: ${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-mega-arm64
1010-
labels: ${{ github.ref_type == 'branch' && github.ref_name != 'main' && 'quay.expires-after=10w' || '' }}
1011999
build-args: |
10121000
BASEIMAGE=${{ env.GHCR_REPO }}:${{ needs.get-version.outputs.image-tag-prefix }}-core-arm64
10131001
VERSION=${{ needs.get-version.outputs.version }}

0 commit comments

Comments
 (0)