Skip to content

Commit e2e87b8

Browse files
committed
ci: add workflow to cleanup untagged container packages
Add automated cleanup workflow that runs weekly to remove untagged container versions from GitHub Container Registry. This helps manage storage usage and prevents accumulation of intermediate build artifacts from the build-container.yml and build-ohpc-lint-container.yml workflows. The workflow includes: - Weekly scheduled cleanup on Sundays at 2 AM UTC - Manual trigger with optional dry-run mode for testing - Cleanup of both main repository and ohpc-lint container images - Configurable retention policies to keep recent versions Signed-off-by: Adrian Reber <[email protected]>
1 parent a7da467 commit e2e87b8

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Cleanup Untagged Packages
2+
3+
on:
4+
schedule:
5+
# Run every Sunday at 02:00 UTC
6+
- cron: '0 2 * * 0'
7+
workflow_dispatch:
8+
inputs:
9+
dry_run:
10+
description: 'Dry run (preview what would be deleted)'
11+
required: false
12+
default: 'false'
13+
type: boolean
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
18+
jobs:
19+
cleanup:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
steps:
25+
- name: Delete untagged container images
26+
uses: actions/delete-package-versions@v5
27+
with:
28+
package-name: ${{ github.repository }}
29+
package-type: container
30+
min-versions-to-keep: 5
31+
delete-only-untagged-versions: true
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
dry-run: ${{ github.event.inputs.dry_run == 'true' }}
34+
35+
- name: Delete old ohpc-lint images
36+
uses: actions/delete-package-versions@v5
37+
with:
38+
package-name: openhpc/ohpc-lint
39+
package-type: container
40+
min-versions-to-keep: 3
41+
delete-only-untagged-versions: true
42+
token: ${{ secrets.GITHUB_TOKEN }}
43+
dry-run: ${{ github.event.inputs.dry_run == 'true' }}
44+
45+
- name: Delete old package versions (keep recent tagged)
46+
uses: actions/delete-package-versions@v5
47+
with:
48+
package-name: ${{ github.repository }}
49+
package-type: container
50+
min-versions-to-keep: 10
51+
oldest-to-delete: 30 # Delete versions older than 30 days
52+
token: ${{ secrets.GITHUB_TOKEN }}
53+
dry-run: ${{ github.event.inputs.dry_run == 'true' }}

0 commit comments

Comments
 (0)