-
Notifications
You must be signed in to change notification settings - Fork 923
Expand file tree
/
Copy pathignore-vercel.sh
More file actions
executable file
·74 lines (62 loc) · 2.03 KB
/
ignore-vercel.sh
File metadata and controls
executable file
·74 lines (62 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Vercel ignore build step script
# Configured here: https://vercel.com/gitbutler/gitbutler-web/settings/git
# Script checks if there are changes in specific directories
# Exit code 0 = skip build, Exit code 1 = proceed
echo "🔍 Checking for changes in monitored directories..."
# Directories to monitor for changes
MONITORED_PATHS=(
# webapp source
"apps/web"
"packages/shared"
"packages/core"
# dependency changes that may affect webapp
"package.json"
"pnpm-lock.yaml"
# the install script is bundled in the webapp
"scripts/install.sh"
)
# Check if we're in a git repository
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "❌ Not in a git repository. Proceeding with build."
exit 1
fi
# Get the previous commit SHA
if [ -n "$VERCEL_GIT_PREVIOUS_SHA" ]; then
PREVIOUS_COMMIT="$VERCEL_GIT_PREVIOUS_SHA"
echo "📊 Using Vercel previous deployment SHA: $PREVIOUS_COMMIT"
elif git rev-parse --verify HEAD^ > /dev/null 2>&1; then
PREVIOUS_COMMIT="HEAD^"
echo "📊 Using previous commit (HEAD^) as fallback"
else
echo "⚠️ No previous commit reference found. Proceeding with build."
exit 1
fi
# Verify the previous commit exists in the repository
if ! git rev-parse --verify "$PREVIOUS_COMMIT" > /dev/null 2>&1; then
echo "⚠️ Previous commit $PREVIOUS_COMMIT not found in repository. Proceeding with build."
exit 1
fi
echo "📊 Comparing $PREVIOUS_COMMIT with HEAD"
# Check each monitored path for changes
HAS_CHANGES=false
for path in "${MONITORED_PATHS[@]}"; do
if [ -d "$path" ] || [ -f "$path" ]; then
if ! git diff --quiet "$PREVIOUS_COMMIT" HEAD -- "$path"; then
echo "✅ Changes detected in: $path"
HAS_CHANGES=true
else
echo "➖ No changes in: $path"
fi
else
echo "⚠️ No such file or directory: $path"
fi
done
echo ""
if [ "$HAS_CHANGES" = true ]; then
echo "🚀 Changes detected in monitored paths. Proceeding with build."
exit 1 # Build
else
echo "🛑 No relevant changes detected. Skipping build."
exit 0 # Skip build
fi