Skip to content

Instantly share code, notes, and snippets.

@quantizor
Created May 11, 2021 14:37
Show Gist options
  • Save quantizor/cf7cbec809f1695f91e0fb5ce8cd0f9b to your computer and use it in GitHub Desktop.
Save quantizor/cf7cbec809f1695f91e0fb5ce8cd0f9b to your computer and use it in GitHub Desktop.
Vercel Ignored Build Step Diff Branch Against Master/Main
# Vercel only performs a depth=2 shallow repository clone, which makes performing branch-level diffs against your main branch
# impossible without manually fetching more data from git
#
# The following command checks if the origin remote is already set up and fetches it if not, then it performs a diff
# of the current branch being built against `main` (replace with `master` if your project is legacy)
#
# The bang (!) before `git diff` inverts the result because Vercel expects an exit code of 1 for triggering a new build
#
# Finally, if you want to filter the file list for only certain directory or file changes, you can add something like
# this after the `git diff ...` statement:
# git diff --name-only origin/main...origin/$VERCEL_GIT_COMMIT_REF | grep -E 'stacks/web'
git config remote.origin.url >&- || git remote add -f origin https://[yourAccessToken]@github.com/[yourRepositoryURL]; \
! git diff --name-only origin/main...origin/$VERCEL_GIT_COMMIT_REF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment