File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ name : " Prune all GHCR image versions"
2+
3+ on :
4+ push :
5+ branches : [ docker ]
6+
7+ permissions :
8+ contents : read
9+ packages : write
10+
11+ jobs :
12+ prune :
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Install dependencies
17+ run : |
18+ sudo apt-get update
19+ sudo apt-get install -y jq
20+ curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
21+ | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
22+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
23+ | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
24+ sudo apt-get update
25+ sudo apt-get install -y gh
26+
27+ - name : Delete **all** versions of CPU & GPU images
28+ env :
29+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
30+ OWNER : ${{ github.repository_owner }}
31+ run : |
32+ set -euo pipefail
33+
34+ for IMAGE in deep-learning-crash-course deep-learning-crash-course-gpu; do
35+ echo
36+ echo "🔍 Processing package: $OWNER/$IMAGE"
37+
38+ # Fetch all versions (paginated)
39+ versions=$(gh api --paginate \
40+ -H "Accept: application/vnd.github.v3+json" \
41+ /orgs/$OWNER/packages/container/$IMAGE/versions)
42+
43+ # Delete every version ID
44+ echo "$versions" | jq -r '.[].id' | while read id; do
45+ echo "→ Deleting version $id of $IMAGE"
46+ for attempt in 1 2 3; do
47+ if gh api -X DELETE \
48+ -H "Accept: application/vnd.github.v3+json" \
49+ /orgs/$OWNER/packages/container/$IMAGE/versions/$id; then
50+ echo " ✅ Deleted $id"
51+ break
52+ else
53+ echo " ⚠️ Attempt $attempt failed, retrying in $((5*attempt))s…"
54+ sleep $((5*attempt))
55+ fi
56+ done
57+ done
58+ done
You can’t perform that action at this time.
0 commit comments