Skip to content

build(vercel): Skip deployment when only backend files change#114029

Merged
vgrozdanic merged 10 commits intomasterfrom
build/vercel-ignore-backend-changes
Apr 28, 2026
Merged

build(vercel): Skip deployment when only backend files change#114029
vgrozdanic merged 10 commits intomasterfrom
build/vercel-ignore-backend-changes

Conversation

@vgrozdanic
Copy link
Copy Markdown
Member

@vgrozdanic vgrozdanic commented Apr 27, 2026

Currently we have a Vercel build on every commit, which is quite expensive, especially when it's useless in cases when there are no frontend changes

Add an ignoreCommand (Vercel docs) to vercel.json that checks whether any frontend-relevant files were modified in the pushed commit. When changes are limited to backend code (Python, Django, tests, etc.), Vercel skips the build entirely.

The command exits 1 (build proceeds) when any of these paths changed: static/, build-utils/, package.json, pnpm-lock.yaml, tsconfig.json, rspack.config.ts, vercel.json, .vercelignore, or config/. It exits 0 (skip) otherwise.

This matches the file allowlist already defined in .vercelignore, so the set of triggering paths mirrors what actually ends up in the Vercel build.

Add an ignoreCommand that checks whether any frontend-relevant files
were modified. Vercel will skip the build when changes are limited to
backend code, reducing unnecessary deployments.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 27, 2026
@vgrozdanic vgrozdanic requested a review from a team April 27, 2026 10:57
@vgrozdanic vgrozdanic marked this pull request as ready for review April 27, 2026 10:57
@vgrozdanic vgrozdanic requested a review from a team as a code owner April 27, 2026 10:58
@vgrozdanic vgrozdanic requested a review from a team April 27, 2026 10:58
Comment thread vercel.json Outdated
Comment thread vercel.json Outdated
Comment thread vercel.json Outdated
The ignoreCommand regex was missing src/sentry/locale/ and
src/sentry/static/images/logos/, both of which are whitelisted in
.vercelignore as build inputs. Changes to those paths would silently
skip deployments, leaving previews with stale translations or logos.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread vercel.json Outdated
Copy link
Copy Markdown
Member

@kenzoengineer kenzoengineer left a comment

Choose a reason for hiding this comment

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

Pretty sure the comment about "single-commit branch"es isn't relevant, PRs with branches off master will point to the commit they branched off from.

what if we want to force a preview build? is there a way to do so in vercel? or an easy way to do so in a PR?

Comment thread vercel.json Outdated
@@ -29,5 +29,6 @@
]
}
],
"github": {"silent": true}
"github": {"silent": true},
"ignoreCommand": "! git diff HEAD^ HEAD --name-only | grep -qE '^(static/|build-utils/|src/sentry/locale/|src/sentry/static/images/logos/|package\\.json|pnpm-lock\\.yaml|tsconfig\\.json|rspack\\.config\\.ts|vercel\\.json|\\.vercelignore|config/)'"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

config/ isn't relevant - can remove.

otherwise lgtm

@vgrozdanic
Copy link
Copy Markdown
Member Author

what if we want to force a preview build? is there a way to do so in vercel? or an easy way to do so in a PR?

@kenzoengineer you can add that file in the config temporarily if needed, but I'd then just fix the vercel.json if we need to force a preview build. That probably means that we missed a file that needs to be previewed.

Comment thread vercel.json Outdated
Comment thread vercel.json Outdated
Compare against VERCEL_GIT_PREVIOUS_SHA when available so pushes with multiple commits do not miss earlier frontend changes. Fall back to HEAD^ when the previous deployment SHA is unavailable, and default to building when git history cannot be resolved instead of silently skipping the deploy.

Also fix the allowlist entries for rspack.config.ts and the logo asset path, and drop config/ from the frontend trigger set because it does not affect Vercel previews.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c7d70ca. Configure here.

Comment thread vercel.json Outdated
Treat the full src/sentry/static/sentry/images tree as a frontend build input so preview deployments rebuild when shared assets like favicons change, not just when logo files change.

Keep .vercelignore aligned with the same asset scope so the upload allowlist matches the ignoreCommand trigger set.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Keep config/ out of the ignoreCommand trigger set, but continue uploading it to Vercel. The frontend build scripts reference files under config/, so removing the directory from .vercelignore can break preview builds even when config changes should not by themselves trigger a deployment.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Drop the nested sh -c wrapper from ignoreCommand and keep the same diff logic inline. Vercel already evaluates ignoreCommand in a shell, so the extra wrapper only adds quoting complexity around the deployment gate.

This preserves the deploy-base fallback and build-trigger allowlist while keeping the command closer to the original working shape.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Keep vercel.json simple by moving the ignoreCommand logic into a checked-in shell script under build-utils/. This avoids fragile JSON escaping and keeps the deployment gate readable while preserving the same deploy-base fallback and frontend allowlist.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Inline the ignoreCommand back into vercel.json and remove the helper script. This keeps the preview build gate easy to read while preserving the fixed frontend allowlist and the safe fallback of building when HEAD^ is unavailable.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Comment thread vercel.json Outdated
@vgrozdanic vgrozdanic force-pushed the build/vercel-ignore-backend-changes branch from a6413c4 to 64b9a6e Compare April 28, 2026 09:16
@vgrozdanic vgrozdanic merged commit 22cbc48 into master Apr 28, 2026
55 of 56 checks passed
@vgrozdanic vgrozdanic deleted the build/vercel-ignore-backend-changes branch April 28, 2026 12:04
cleptric pushed a commit that referenced this pull request May 5, 2026
Currently we have a Vercel build on every commit, which is quite
expensive, especially when it's useless in cases when there are no
frontend changes

Add an `ignoreCommand` ([Vercel
docs](https://vercel.com/docs/project-configuration/vercel-json#ignorecommand))
to `vercel.json` that checks whether any frontend-relevant files were
modified in the pushed commit. When changes are limited to backend code
(Python, Django, tests, etc.), Vercel skips the build entirely.

The command exits `1` (build proceeds) when any of these paths changed:
`static/`, `build-utils/`, `package.json`, `pnpm-lock.yaml`,
`tsconfig.json`, `rspack.config.ts`, `vercel.json`, `.vercelignore`, or
`config/`. It exits `0` (skip) otherwise.

This matches the file allowlist already defined in `.vercelignore`, so
the set of triggering paths mirrors what actually ends up in the Vercel
build.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants