File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Delete Untagged GHCR Containers
2+
3+ on :
4+ schedule :
5+ # Runs at 00:00 UTC every day
6+ - cron : ' 0 0 * * *'
7+
8+ jobs :
9+ cleanup-untagged-containers :
10+ runs-on : ubuntu-latest
11+ permissions :
12+ contents : read
13+ packages : write
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v2
18+
19+ - name : Set up GitHub CLI
20+ uses : actions/setup-cli@v2
21+
22+ - name : Authenticate with GitHub Container Registry
23+ run : echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
24+
25+ - name : List and Delete Untagged Containers
26+ env :
27+ GHCR_PACKAGE_NAME : devx-devcontainer
28+ OWNER : input-output-hk
29+ run : |
30+ untagged_images=$(gh api -X GET /user/packages/container/$GHCR_PACKAGE_NAME/versions --paginate --jq '.[] | select(.metadata.container.tags | length == 0) | .id')
31+ for image_id in $untagged_images; do
32+ echo "Deleting untagged container image with ID: $image_id"
33+ gh api -X DELETE /user/packages/container/$GHCR_PACKAGE_NAME/versions/$image_id
34+ done
You can’t perform that action at this time.
0 commit comments