Skip to content

Commit 7d8af66

Browse files
committed
ci: weekly GHCR housekeeping (keep last 10 tagged + prune untagged)
1 parent 2ae57d6 commit 7d8af66

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

.github/workflows/cleanup-ghcr.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: GHCR Image Housekeeping
2+
3+
# Weekly sweep + on-demand. Keeps the GHCR package small without
4+
# operator action. Safety net: keeps the 10 most recent tagged versions
5+
# AND prunes untagged manifest lists (intermediate/PR builds that no
6+
# one references). See:
7+
# https://github.com/actions/delete-package-versions
8+
#
9+
# To dry-run, trigger manually with dry-run=true under workflow_dispatch.
10+
11+
on:
12+
schedule:
13+
# Sundays at 03:29 UTC. Off-hours, off the :00 / :30 minute marks.
14+
# Different minute than the agent + dashboard repos.
15+
- cron: '29 3 * * 0'
16+
workflow_dispatch:
17+
inputs:
18+
dry-run:
19+
description: 'List versions that would be deleted without deleting them'
20+
type: boolean
21+
default: false
22+
23+
concurrency:
24+
group: cleanup-ghcr-${{ github.workflow }}
25+
cancel-in-progress: false
26+
27+
env:
28+
PACKAGE_NAME: agentic-taf
29+
KEEP_TAGGED: 10
30+
31+
jobs:
32+
prune-untagged:
33+
name: Prune untagged manifests
34+
runs-on: ubuntu-latest
35+
permissions:
36+
packages: write
37+
steps:
38+
- name: Delete untagged versions
39+
uses: actions/delete-package-versions@v5
40+
with:
41+
package-name: ${{ env.PACKAGE_NAME }}
42+
package-type: container
43+
delete-only-untagged-versions: true
44+
min-versions-to-keep: 5
45+
dry-run: ${{ inputs.dry-run || false }}
46+
47+
prune-old-tagged:
48+
name: Prune old tagged versions
49+
runs-on: ubuntu-latest
50+
permissions:
51+
packages: write
52+
steps:
53+
- name: Delete old tagged versions (keep last 10)
54+
uses: actions/delete-package-versions@v5
55+
with:
56+
package-name: ${{ env.PACKAGE_NAME }}
57+
package-type: container
58+
min-versions-to-keep: ${{ env.KEEP_TAGGED }}
59+
ignore-versions: '^(latest|stable|main)$'
60+
dry-run: ${{ inputs.dry-run || false }}

0 commit comments

Comments
 (0)