Skip to content

Commit a51bc06

Browse files
committed
Move Vercel build ignore logic to standalone script for clarity and reusability
1 parent b476cb7 commit a51bc06

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

web/scripts/vercel-ignore.sh

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

web/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"headers": [{"key": "Cache-Control", "value": "no-cache"}]
1010
}
1111
],
12-
"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/"
12+
"ignoreCommand": "bash scripts/vercel-ignore.sh"
1313
}

0 commit comments

Comments
 (0)