diff --git a/.gitea/workflows/build-push.yml b/.gitea/workflows/build-push.yml index 6dfe2f8..35d69c8 100644 --- a/.gitea/workflows/build-push.yml +++ b/.gitea/workflows/build-push.yml @@ -39,9 +39,20 @@ jobs: REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }} REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }} + - name: Delete old latest image + run: | + # Delete old :latest tag from Forgejo registry via API + curl -s -X DELETE \ + -u "${REGISTRY_USER}:${REGISTRY_TOKEN}" \ + "https://${REGISTRY}/v2/rock/portfolio/manifests/$(curl -s -H 'Accept: application/vnd.oci.image.index.v1+json' -u "${REGISTRY_USER}:${REGISTRY_TOKEN}" "https://${REGISTRY}/v2/rock/portfolio/manifests/latest" | head -1 | grep -o 'sha256:[a-f0-9]*' || true)" \ + 2>/dev/null || echo "No old latest to delete" + env: + REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }} + REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }} + - name: Build image run: | - docker build \ + docker build --no-cache \ -t "${IMAGE}:${{ steps.sha.outputs.short_sha }}" \ -t "${IMAGE}:latest" \ .