Move Vercel build ignore logic to standalone script for clarity and reusability

This commit is contained in:
MartinBraquet
2026-07-30 20:11:06 +02:00
parent b476cb7a8c
commit a51bc06029
2 changed files with 16 additions and 1 deletions

15
web/scripts/vercel-ignore.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Vercel `ignoreCommand`: exit 0 to skip the build, non-zero to build.
# Skips the build when neither web/ nor common/ changed since the previous deployed commit.
# Kept in a script (rather than inline in vercel.json) because `ignoreCommand` is capped at 256 chars.
git fetch origin --unshallow || git fetch origin --deepen=200 || true
echo "prev=$VERCEL_GIT_PREVIOUS_SHA cur=$VERCEL_GIT_COMMIT_SHA"
if [ -z "$VERCEL_GIT_PREVIOUS_SHA" ] || ! git cat-file -e "$VERCEL_GIT_PREVIOUS_SHA^{commit}" 2>/dev/null; then
echo 'no usable previous sha - building'
exit 1
fi
git diff --quiet "$VERCEL_GIT_PREVIOUS_SHA" "$VERCEL_GIT_COMMIT_SHA" -- ./ ../common/

View File

@@ -9,5 +9,5 @@
"headers": [{"key": "Cache-Control", "value": "no-cache"}]
}
],
"ignoreCommand": "git fetch origin --unshallow || git fetch origin --deepen=200 || true; echo \"prev=$VERCEL_GIT_PREVIOUS_SHA cur=$VERCEL_GIT_COMMIT_SHA\"; if [ -z \"$VERCEL_GIT_PREVIOUS_SHA\" ] || ! git cat-file -e \"$VERCEL_GIT_PREVIOUS_SHA^{commit}\" 2>/dev/null; then echo 'no usable previous sha - building'; exit 1; fi; git diff --quiet \"$VERCEL_GIT_PREVIOUS_SHA\" \"$VERCEL_GIT_COMMIT_SHA\" -- ./ ../common/"
"ignoreCommand": "bash scripts/vercel-ignore.sh"
}