Skip to content

Commit

Permalink
CI: periodically remove untagged images
Browse files Browse the repository at this point in the history
We keep overwriting tags, so the package accumulates old untagged
images. Remove images without a tag once a day.

Signed-off-by: Lorenz Bauer <[email protected]>
  • Loading branch information
lmb committed Jan 30, 2024
1 parent 78c2aa2 commit e7a3230
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Cleanup Untagged Images

on:
workflow_dispatch: []
schedule:
- cron: '1 23 * * *'

permissions:
packages: write

jobs:
cleanup:
runs-on: ubuntu-latest

- name: Remove untagged images
run: |
ids=$(gh api -X GET "/orgs/${{ github.repository_owner }}/packages/container/ci-kernels/versions" -f package_type=container -F per_page=2 -q '.[] | select(.metadata.container.tags | length == 0) | .id')
for id in $ids; do
echo "Deleting untagged image with ID: $id"
gh api -X DELETE "/orgs/${{ github.repository_owner }}/packages/container/ci-kernels/versions/$id"
fi
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit e7a3230

Please sign in to comment.