Preserve referenced image manifests during cleanup
This commit is contained in:
1 parent
abd0763fe5
commit
14bba3f94b
2 files changed
+13
-2
No files matched your search
@@ -52,11 +52,13 @@ jobs:
|
||||
|
||||
- name: Remove old image versions
|
||||
env:
|
||||
BUILD_DIGEST: ${{ needs.build.outputs.digest }}
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
command -v jq >/dev/null
|
||||
api='https://gt.uo1.net/api/v1/packages/1movmedia/container/ollama-with-model'
|
||||
current_manifest=$(docker buildx imagetools inspect "${IMAGE_NAME}:latest" --raw)
|
||||
while :; do
|
||||
response=$(curl --fail --silent --show-error \
|
||||
--header "Authorization: token ${REGISTRY_TOKEN}" \
|
||||
@@ -64,9 +66,18 @@ jobs:
|
||||
versions=$(printf '%s\n' "$response" \
|
||||
| jq --raw-output '.[] | select(.version != "latest") | .version')
|
||||
[ -n "$versions" ] || break
|
||||
printf '%s\n' "$versions" | while IFS= read -r version; do
|
||||
deleted=false
|
||||
for version in $versions; do
|
||||
if [ "$version" = "$BUILD_DIGEST" ] \
|
||||
|| printf '%s\n' "$current_manifest" | jq --exit-status \
|
||||
--arg version "$version" \
|
||||
'any(.manifests[]?; .digest == $version)' >/dev/null; then
|
||||
continue
|
||||
fi
|
||||
curl --fail --silent --show-error --request DELETE \
|
||||
--header "Authorization: token ${REGISTRY_TOKEN}" \
|
||||
"${api}/${version}"
|
||||
deleted=true
|
||||
done
|
||||
"$deleted" || break
|
||||
done
|
||||
Reference in new issue
Block a user