Skip to content

Commit 2205f71

Browse files
committed
rebuild
1 parent 94489a4 commit 2205f71

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

.github/workflows/cleanup-ghcr.yml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
sudo apt-get update
2929
sudo apt-get install -y gh
3030
31-
- name: Delete all non-`:latest` versions
31+
- name: Re-tag newest as “latest” and prune the rest
3232
env:
3333
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434
OWNER: ${{ github.repository_owner }}
@@ -37,29 +37,27 @@ jobs:
3737
3838
for IMAGE in deep-learning-crash-course deep-learning-crash-course-gpu; do
3939
echo
40-
echo "🔍 Processing package: $OWNER/$IMAGE"
40+
echo "🔍 Processing $OWNER/$IMAGE"
4141
versions=$(gh api --paginate \
4242
-H "Accept: application/vnd.github.v3+json" \
4343
/orgs/$OWNER/packages/container/$IMAGE/versions)
4444
45-
# Only delete versions *not* tagged "latest"
46-
echo "$versions" \
47-
| jq -c '.[] | select((.metadata.container.tags // []) | index("latest") | not)' \
48-
| while read version; do
45+
# pick the newest by creation date
46+
newest_id=$(echo "$versions" \
47+
| jq -r 'sort_by(.created_at) | last | .id')
48+
echo "🛡 Retagging version $newest_id as latest"
49+
gh api -X POST \
50+
-H "Accept: application/vnd.github.v3+json" \
51+
/orgs/$OWNER/packages/container/$IMAGE/versions/$newest_id/tags \
52+
-f name=latest
4953
50-
id=$(echo "$version" | jq -r '.id')
51-
tags=$(echo "$version" | jq -r '.metadata.container.tags[]')
52-
echo "→ Deleting version $id (tags: $tags)"
53-
for attempt in 1 2 3; do
54-
if gh api -X DELETE \
55-
-H "Accept: application/vnd.github.v3+json" \
56-
/orgs/$OWNER/packages/container/$IMAGE/versions/$id; then
57-
echo " ✅ Deleted $id"
58-
break
59-
else
60-
echo " ⚠️ Attempt $attempt failed, retrying…"
61-
sleep $((5*attempt))
62-
fi
54+
# delete all other versions
55+
echo "$versions" \
56+
| jq -r --arg keep "$newest_id" '.[] | select(.id != ($keep|tonumber)) | .id' \
57+
| while read id; do
58+
echo "→ Deleting version $id"
59+
gh api -X DELETE \
60+
-H "Accept: application/vnd.github.v3+json" \
61+
/orgs/$OWNER/packages/container/$IMAGE/versions/$id
6362
done
64-
done
6563
done

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
- 'docker/requirements.txt'
1010
- 'docker/docker-compose.yml'
1111
- '.github/workflows/docker-publish.yml'
12-
- 'docker/.vscode/settings.json'
1312
pull_request:
1413
branches: [ docker ]
1514
paths:
@@ -18,7 +17,6 @@ on:
1817
- 'docker/requirements.txt'
1918
- 'docker/docker-compose.yml'
2019
- '.github/workflows/docker-publish.yml'
21-
- 'docker/.vscode/settings.json'
2220

2321

2422
env:

0 commit comments

Comments
 (0)