Preserve referenced image manifests during cleanup
Publish container image / build (push) Successful in 13m47s
Publish container image / publish (push) Successful in 15s

This commit is contained in:
Mikhail Yevchenko committed 2026-08-24 12:24:07 +03:00
1 parent abd0763fe5
commit 14bba3f94b
2 files changed
+13 -2

No files matched your search

+12 -1
View File
@@ -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
+1 -1
View File
@@ -46,7 +46,7 @@ Building downloads the complete model, so the runner needs enough disk space for
## 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: