fix(prune): paginate package list so old tags past page 1 are actually pruned

The org now has more container versions than one API page returns; the
unpaginated list dropped a package's older numeric tags, so KEEP-based
pruning silently left them (base/runner crept to 5). Loop pages at the
max page size instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Donavan Fritz
2026-06-25 21:21:23 -05:00
parent b1112bbbd5
commit f1dbdafb0c
+12 -2
View File
@@ -65,9 +65,19 @@ runs:
set -euo pipefail set -euo pipefail
tea login add --name ci --url https://code.fritzlab.net \ tea login add --name ci --url https://code.fritzlab.net \
--token "$TOKEN" --no-version-check >/dev/null 2>&1 || true --token "$TOKEN" --no-version-check >/dev/null 2>&1 || true
tea api "/packages/${ORG}?type=container" \ # Paginate the package list. The org has more container versions than a
| jq -r --arg n "$NAME" \ # single API page returns (Gitea caps page size at MAX_RESPONSE_ITEMS),
# so an unpaginated call silently drops a package's older tags from the
# list and they never get pruned — that's how tags crept past KEEP.
page=1
while :; do
resp=$(tea api "/packages/${ORG}?type=container&limit=50&page=${page}")
[ "$(jq 'length' <<<"$resp")" -eq 0 ] && break
jq -r --arg n "$NAME" \
'.[] | select(.name==$n) | select(.version | test("^[0-9]+$")) | .version' \ '.[] | select(.name==$n) | select(.version | test("^[0-9]+$")) | .version' \
<<<"$resp"
page=$((page + 1))
done \
| sort -n | head -n -"$KEEP" \ | sort -n | head -n -"$KEEP" \
| while read -r tag; do | while read -r tag; do
echo "deleting ${NAME}:$tag" echo "deleting ${NAME}:$tag"