update to add rolling ghcr docker image

This commit is contained in:
Huaaudio 2026-03-09 06:56:58 +01:00
parent 99596679d1
commit ff7f8c8bfa

View file

@ -165,3 +165,34 @@ jobs:
gh release delete "$old_tag" --cleanup-tag -y || true
fi
done
echo "Cleaning up all untagged Docker images on GHCR..."
# Get all version IDs for the package that have no tags
UNTAGGED_VERSIONS=$(gh api -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/user/packages/container/picoclaw/versions \
--jq '.[] | select((.metadata.container.tags | length) == 0) | .id' 2>/dev/null || true)
for version_id in $UNTAGGED_VERSIONS; do
if [ -n "$version_id" ]; then
echo "Deleting untagged Docker image version ID: $version_id"
gh api --method DELETE -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/user/packages/container/picoclaw/versions/$version_id" || true
fi
done
echo "Cleaning up old 'nightly-YYYYMMDD-SHA' Docker images on GHCR..."
# Fetch all version IDs where at least one tag starts with "nightly-", excluding the current newly created $TAG
OLD_NIGHTLY_VERSIONS=$(gh api -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/user/packages/container/picoclaw/versions \
--jq ".[] | select(.metadata.container.tags[] | startswith(\"nightly-\") and (. != \"nightly\") and (. != \"$TAG\")) | .id" 2>/dev/null || true)
for version_id in $OLD_NIGHTLY_VERSIONS; do
if [ -n "$version_id" ]; then
echo "Deleting old nightly Docker image version ID: $version_id"
gh api --method DELETE -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/user/packages/container/picoclaw/versions/$version_id" || true
fi
done