Skip to content

ci(docs): skip Vercel preview builds when docs/ unchanged - #1399

Merged
f-trycua merged 1 commit into
mainfrom
ci/docs-skip-build-on-non-docs-changes
Apr 27, 2026
Merged

ci(docs): skip Vercel preview builds when docs/ unchanged#1399
f-trycua merged 1 commit into
mainfrom
ci/docs-skip-build-on-non-docs-changes

Conversation

@f-trycua

@f-trycua f-trycua commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Vercel currently builds a docs preview on every PR, even ones that don't touch docs/ (e.g. #1378, which is a cua-driver-only fix). Add an ignoreCommand to docs/vercel.json so Vercel skips the build when nothing under the project root has changed.

How it works

Vercel runs ignoreCommand from the configured project root (already docs/). The command exits 0 → skip build, exit 1 → continue.

git diff --quiet HEAD^ HEAD ./

./ is relative to the Vercel project root, so the diff is naturally scoped to docs/. PRs that touch any file under docs/ still get a preview; PRs that don't are skipped immediately.

Test plan

  • After merge, open a non-docs PR and confirm Vercel reports "Build skipped"
  • Open a docs-only PR and confirm a preview deploys as before

Summary by CodeRabbit

  • Chores
    • Optimized build configuration to skip deployments when documentation remains unchanged, improving deployment efficiency.

Vercel was deploying a preview for every PR even when nothing under
docs/ changed (e.g. cua-driver-only PRs). Add an ignoreCommand that
exits 0 — i.e. skip — when git diff finds no changes scoped to the
project root (docs/).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 27, 2026 0:46am

Request Review

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A new ignoreCommand configuration property is added to docs/vercel.json with the value git diff --quiet HEAD^ HEAD ./, enabling conditional deployment logic based on file modifications in the docs directory.

Changes

Cohort / File(s) Summary
Vercel Configuration
docs/vercel.json
Added ignoreCommand field to control deployment triggering based on changes to the docs directory.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A config tweak, so small and neat,
Deployment now won't skip a beat,
Docs unchanged means no rebuild,
With ignoreCommand wisely filled! 📝✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding configuration to skip Vercel preview builds when docs/ are unchanged.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/docs-skip-build-on-non-docs-changes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
docs/vercel.json (1)

7-8: Note: git diff HEAD^ HEAD in shallow clones may fail if the parent commit is beyond the clone depth, but this is a documented pattern that Vercel explicitly recommends.

The git diff --quiet HEAD^ HEAD ./ command can encounter issues in Vercel's shallow clones (depth=10), where HEAD^ may not exist if the parent commit is beyond the depth. However, Vercel's official documentation acknowledges this and still recommends this pattern as the standard approach—the safe fallback behavior (build continues on error) mitigates the risk.

If you prefer more robust change detection, use Vercel's environment variables instead:

More reliable alternative using Vercel environment variables
-  "ignoreCommand": "git diff --quiet HEAD^ HEAD ./"
+  "ignoreCommand": "git diff --quiet $VERCEL_GIT_PREVIOUS_SHA $VERCEL_GIT_COMMIT_SHA ./"

This uses VERCEL_GIT_PREVIOUS_SHA (the SHA of the last successful deployment) rather than git history, eliminating shallow clone limitations. Note: Requires "Automatically Expose System Environment Variables" to be enabled, and VERCEL_GIT_PREVIOUS_SHA will be empty on the first deployment of a new branch.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/vercel.json` around lines 7 - 8, The ignoreCommand using the literal
"git diff --quiet HEAD^ HEAD ./" can fail in shallow Vercel clones where HEAD^
is unavailable; update the Vercel config to use Vercel-provided env vars instead
by replacing the ignoreCommand logic to check VERCEL_GIT_PREVIOUS_SHA vs
VERCEL_GIT_COMMIT_SHA (or fall back when VERCEL_GIT_PREVIOUS_SHA is empty) so
change detection does not rely on git history; locate the "ignoreCommand" entry
in the JSON and implement a check that uses
VERCEL_GIT_PREVIOUS_SHA/VERCEL_GIT_COMMIT_SHA (with a safe default to allow the
build when the previous SHA is missing).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/vercel.json`:
- Around line 7-8: The ignoreCommand using the literal "git diff --quiet HEAD^
HEAD ./" can fail in shallow Vercel clones where HEAD^ is unavailable; update
the Vercel config to use Vercel-provided env vars instead by replacing the
ignoreCommand logic to check VERCEL_GIT_PREVIOUS_SHA vs VERCEL_GIT_COMMIT_SHA
(or fall back when VERCEL_GIT_PREVIOUS_SHA is empty) so change detection does
not rely on git history; locate the "ignoreCommand" entry in the JSON and
implement a check that uses VERCEL_GIT_PREVIOUS_SHA/VERCEL_GIT_COMMIT_SHA (with
a safe default to allow the build when the previous SHA is missing).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 85c51930-1885-47cc-adf3-8973a2d1fc93

📥 Commits

Reviewing files that changed from the base of the PR and between 9d76678 and 5d49676.

📒 Files selected for processing (1)
  • docs/vercel.json

@f-trycua
f-trycua merged commit 31a64eb into main Apr 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant