Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/docs/scripts/vercel-ignore-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Vercel's Ignored Build Step for the docs project (`ignoreCommand` in vercel.json), run from
# apps/docs before install. Exit 0 skips the build; exit 1 builds.
#
# Vercel's "skip unaffected projects" already drops commits that touch neither docs nor a
# workspace package it depends on. Of the rest, production and the staging integration branch
# always build, so a shared-package change that breaks the docs build still fails on staging
# before it reaches main. Any other preview branch builds only when it changes docs itself.
#
# Anything this script cannot decide builds: a branch's first deployment (no previous SHA) and a
# previous deployment outside the shallow clone.
set -uo pipefail

if [[ "${VERCEL_ENV:-}" == production || "${VERCEL_GIT_COMMIT_REF:-}" == staging ]]; then
exit 1
fi

previous=${VERCEL_GIT_PREVIOUS_SHA:-}
if [[ -z "$previous" ]] || ! git cat-file -e "${previous}^{commit}" 2> /dev/null; then
echo "No previous deployment in this clone; building."
exit 1
fi

if git diff --quiet "$previous" HEAD -- .; then
echo "No docs changes since ${previous}; skipping this preview."
exit 0
fi
exit 1
4 changes: 4 additions & 0 deletions apps/docs/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"ignoreCommand": "bash scripts/vercel-ignore-build.sh"
}
Loading