Vercel ignore build step according to folder of committed files

Viewed 879

i'm using vercel's ignore build step field to disable preview deploys (IE - only deploy if the branch is main)

I'm doing this with the following bash script:

if [[ "$VERCEL_GIT_COMMIT_REF" == "main" ]] ; then
  # Proceed with the build
    echo "✅ - Build can proceed"
  exit 1;
else
  # Don't build
  echo " - Build canceled"
  exit 0;
fi

Now, another requirement I have is to only deploy if the changed files belong to a specific folder. Can I somehow combine these two requirements in the same script?
How do I access the paths of the committed files in this bash script?
Thanks!

1 Answers

Vercel has added some docs that address this exact situation:

git diff HEAD^ HEAD --quiet ./packages/frontend/

If changes were commited to ./packages/frontend/, the command will yield a non-empty response, allowing the build to proceed.

I also use a similar setup, but call a node script (check it out here) as my Ignored Build Step option.

Related