54 - Skip CI image rebuild when the lockfile tag already exists
This commit is contained in:
parent
cb2dbd9299
commit
1e826e7cae
1 changed files with 20 additions and 0 deletions
|
|
@ -32,7 +32,27 @@ jobs:
|
|||
HASH="$(sha256sum composer.lock | cut -c1-12)"
|
||||
echo "tag=php8.3-${HASH}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Check whether image already exists
|
||||
id: exists
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TOKEN="$(curl -sf "https://forge.lvl0.xyz/v2/token?service=container_registry&scope=repository:lvl0/dishplanner-ci:pull" | grep -o '"token":"[^"]*"' | head -n1 | cut -d'"' -f4)"
|
||||
if [ -z "$TOKEN" ]; then
|
||||
echo "Registry token fetch failed; cannot check for an existing image." >&2
|
||||
exit 1
|
||||
fi
|
||||
CODE="$(curl -s -o /dev/null -w '%{http_code}' \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H 'Accept: application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.docker.distribution.manifest.v2+json' \
|
||||
"https://forge.lvl0.xyz/v2/lvl0/dishplanner-ci/manifests/${{ steps.meta.outputs.tag }}")"
|
||||
if [ "$CODE" = "200" ]; then
|
||||
echo "found=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "found=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Build and push CI image
|
||||
if: steps.exists.outputs.found == 'false'
|
||||
uses: https://data.forgejo.org/docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
|
|
|
|||
Loading…
Reference in a new issue