Skip to content

Commit 50fc27d

Browse files
authored
ci: Cleanup old build cache images (IBM#42)
Every successful push to main produces new build cache images on ghcr.io which currently have to be cleaned up manually. Add actions/delete-package-versions after successful push of a new cache image (implicit). --------- Signed-off-by: Christian Kadner <[email protected]>
1 parent 5587fe9 commit 50fc27d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ defaults:
2424
env:
2525
CI: true
2626
SERVER_IMAGE_NAME: "text-gen-server:0"
27+
SERVER_IMAGE: "ghcr.io/ibm/text-gen-server:latest" # TODO: consider publishing to quay.io or icr.io instead
2728

2829
jobs:
2930
build:
@@ -34,8 +35,8 @@ jobs:
3435
env:
3536
CACHE_IMAGE: "ghcr.io/ibm/text-gen-server:build-cache"
3637
CACHE_REGISTRY: "ghcr.io"
37-
SERVER_IMAGE: "ghcr.io/ibm/text-gen-server:latest" # TODO: don't push final image as a package to ghcr.io
38-
38+
CACHE_PACKAGE_NAME: "text-gen-server"
39+
3940
steps:
4041
- name: "Checkout"
4142
uses: actions/checkout@v4
@@ -86,6 +87,14 @@ jobs:
8687
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}
8788
cache-to: ${{ env.CACHE_TO }}
8889
push: ${{ github.event_name != 'pull_request' }}
90+
91+
- name: "Cleanup old cache images"
92+
uses: actions/delete-package-versions@v5
93+
if: ${{ github.event_name == 'push' }}
94+
with:
95+
package-name: ${{ env.CACHE_PACKAGE_NAME }}
96+
package-type: container
97+
delete-only-untagged-versions: true
8998

9099
- name: "List docker images"
91100
run: docker images

0 commit comments

Comments
 (0)