Repository navigation
SEL-454: Vercel previews only for frontend changes #3521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,47 @@ | ||||||||||||||||||||||||
| #!/bin/sh | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| case "${VERCEL_GIT_COMMIT_REF:-}" in dependabot/*) echo 'Dependabot branch, skipping preview'; exit 0;; esac | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if [ "${VERCEL_ENV:-}" = "production" ]; then | ||||||||||||||||||||||||
| echo "Production build, building" | ||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| BASE="" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if [ -n "${VERCEL_GIT_PREVIOUS_SHA:-}" ]; then | ||||||||||||||||||||||||
| if git cat-file -e "${VERCEL_GIT_PREVIOUS_SHA}^{commit}" 2>/dev/null; then | ||||||||||||||||||||||||
| BASE="$VERCEL_GIT_PREVIOUS_SHA" | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis
Fetch the previous deployment commit before the When Fetch that commit when it is missing locally, then check it again: 🛠️ Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if [ -z "$BASE" ]; then | ||||||||||||||||||||||||
| git fetch --quiet --depth=100 origin main 2>/dev/null || true | ||||||||||||||||||||||||
| BASE="$(git merge-base HEAD FETCH_HEAD 2>/dev/null || true)" | ||||||||||||||||||||||||
| if [ -z "$BASE" ]; then | ||||||||||||||||||||||||
| if git cat-file -e origin/main^{commit} 2>/dev/null; then | ||||||||||||||||||||||||
| BASE="origin/main" | ||||||||||||||||||||||||
| elif git rev-parse --verify origin/main >/dev/null 2>&1; then | ||||||||||||||||||||||||
| BASE="origin/main" | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if [ -z "$BASE" ]; then | ||||||||||||||||||||||||
| echo "No base commit found, building" | ||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| git diff --quiet "$BASE" HEAD -- . | ||||||||||||||||||||||||
| STATUS=$? | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if [ "$STATUS" -eq 0 ]; then | ||||||||||||||||||||||||
| echo "No frontend changes, skipping" | ||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||
| elif [ "$STATUS" -eq 1 ]; then | ||||||||||||||||||||||||
| echo "frontend changed, building" | ||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||
| else | ||||||||||||||||||||||||
| echo "Diff failed, building" | ||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Check production before skipping Dependabot refs.
If a production deployment uses a
dependabot/*ref, this line exits with 0 before the production check. Vercel then ignores the build, contrary to the stated requirement to always build production. Move the production check above this branch check. (vercel.com)🤖 Prompt for AI Agents