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
|
- name: Remove old image versions
|
||||||
env:
|
env:
|
||||||
|
BUILD_DIGEST: ${{ needs.build.outputs.digest }}
|
||||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
command -v jq >/dev/null
|
command -v jq >/dev/null
|
||||||
api='https://gt.uo1.net/api/v1/packages/1movmedia/container/ollama-with-model'
|
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
|
while :; do
|
||||||
response=$(curl --fail --silent --show-error \
|
response=$(curl --fail --silent --show-error \
|
||||||
--header "Authorization: token ${REGISTRY_TOKEN}" \
|
--header "Authorization: token ${REGISTRY_TOKEN}" \
|
||||||
@@ -64,9 +66,18 @@ jobs:
|
|||||||
versions=$(printf '%s\n' "$response" \
|
versions=$(printf '%s\n' "$response" \
|
||||||
| jq --raw-output '.[] | select(.version != "latest") | .version')
|
| jq --raw-output '.[] | select(.version != "latest") | .version')
|
||||||
[ -n "$versions" ] || break
|
[ -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 \
|
curl --fail --silent --show-error --request DELETE \
|
||||||
--header "Authorization: token ${REGISTRY_TOKEN}" \
|
--header "Authorization: token ${REGISTRY_TOKEN}" \
|
||||||
"${api}/${version}"
|
"${api}/${version}"
|
||||||
|
deleted=true
|
||||||
done
|
done
|
||||||
|
"$deleted" || break
|
||||||
done
|
done
|
||||||
@@ -46,7 +46,7 @@ Building downloads the complete model, so the runner needs enough disk space for
|
|||||||
|
|
||||||
## Publish from Gitea Actions
|
## Publish from Gitea Actions
|
||||||
|
|
||||||
The workflow in `.gitea/workflows/publish.yml` builds the image by digest, then publishes the `latest` tag in a separate job. After a successful publication, it removes every other version of the image from the Gitea registry. It runs on pushes to `main` and can also be started manually with `workflow_dispatch`.
|
The workflow in `.gitea/workflows/publish.yml` builds the image by digest, then publishes the `latest` tag in a separate job. After a successful publication, it removes old versions while preserving every manifest referenced by the current image. It runs on pushes to `main` and can also be started manually with `workflow_dispatch`.
|
||||||
|
|
||||||
Configure the following repository Actions variable and secret before running it:
|
Configure the following repository Actions variable and secret before running it:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user