Skip to content

Commit 441423d

Browse files
committed
conditional deployment based on commit changes
1 parent 6363778 commit 441423d

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,28 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
paths-ignore:
7+
- "**.md"
8+
- "LICENSE"
9+
- "CODE_OF_CONDUCT"
10+
- ".github/ISSUE_TEMPLATE/**"
11+
- ".vscode/**"
12+
- ".editorconfig"
13+
- ".prettierrc*"
14+
- ".prettierignore"
15+
- "public/llms.txt"
616
pull_request:
717
branches: [main]
18+
paths-ignore:
19+
- "**.md"
20+
- "LICENSE"
21+
- "CODE_OF_CONDUCT"
22+
- ".github/ISSUE_TEMPLATE/**"
23+
- ".vscode/**"
24+
- ".editorconfig"
25+
- ".prettierrc*"
26+
- ".prettierignore"
27+
- "public/llms.txt"
828

929
jobs:
1030
ci:

scripts/should-deploy.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# Vercel Ignored Build Step
3+
# Exit 0 → skip build. Exit 1 → proceed with build.
4+
#
5+
# Skips the Vercel deployment when every changed file is documentation-only
6+
# (markdown, license, editor config, GitHub templates, etc.).
7+
# Any change to app code, data, dependencies, or config triggers a deploy.
8+
9+
set -euo pipefail
10+
11+
# First deploy has no previous SHA — always build.
12+
if [ -z "${VERCEL_GIT_PREVIOUS_SHA:-}" ]; then
13+
echo "→ First deploy — building."
14+
exit 1
15+
fi
16+
17+
CHANGED=$(git diff --name-only "$VERCEL_GIT_PREVIOUS_SHA" "$VERCEL_GIT_COMMIT_SHA" 2>/dev/null)
18+
19+
if [ -z "$CHANGED" ]; then
20+
echo "→ No changed files — skipping."
21+
exit 0
22+
fi
23+
24+
# Patterns that never require a Vercel deploy
25+
DOCS_PATTERN='^(.*\.md|LICENSE|CODE_OF_CONDUCT|\.github/.*|\.vscode/.*|\.editorconfig|\.prettierrc.*|\.prettierignore|public/llms\.txt)$'
26+
27+
while IFS= read -r file; do
28+
if ! echo "$file" | grep -qE "$DOCS_PATTERN"; then
29+
echo "→ Deploy triggered by: $file"
30+
exit 1
31+
fi
32+
done <<< "$CHANGED"
33+
34+
echo "→ Docs-only change — skipping deploy."
35+
exit 0

vercel.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"framework": "nextjs",
33
"buildCommand": "next build",
44
"installCommand": "npm ci",
5+
"ignoreCommand": "bash scripts/should-deploy.sh",
56
"crons": [{ "path": "/api/cron/sync-health", "schedule": "0 2 * * *" }]
67
}

0 commit comments

Comments
 (0)