Skip to content

Commit

Permalink
use GH CLI to delete (dry-run) untagged package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbreen committed Sep 5, 2023
1 parent 549851a commit ab63629
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ jobs:
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
- name: Remove Untagged Container Images
run: |
set -x
gh api /user/packages?package_type=container | jq -r --arg repo {{github.repository}} '.[] | select(.repository.full_name == $repo) | .name' | tee {{runner.temp}}/names.txt
while read package
do
gh api /user/packages/container/${package//\//%2F}/versions | jq -r '.[] | select(.metadata.container.tags==[]) | .id' | tee {{runner.temp}}/ids.txt
while read id
do
echo gh api --method DELETE /user/packages/container/${package//\//%2F}/versions/${id}
done < {{runner.temp}}/ids.txt
done < {{runner.temp}}/names.txt
bazel:
name: Bazel Build & Test
Expand Down

0 comments on commit ab63629

Please sign in to comment.