My vercel project is setup to listen for changes to the web folder in my git repo. Is there a way to prevent extra deployments being counted when I push changes to the git repo that are not in the web folder? Right now it triggers a deployment and then cancels it right away when I push a change that doesn’t modify anything in the web folder. This counts as a deployment. Is there a way to have vercel complely ignore changes made to a repo unless it’s in a certain folder?
You can set up Vercel to trigger deployments only when certain directories change by using the Ignored Build Step. This is a helpful way to avoid unnecessary deployments and save build minutes, especially if you have parts of your project that don’t need to rebuild every time.
Here are two approaches you can use:
Option 1: Configure it in the Dashboard
- Open your project in the Vercel Dashboard
- Go to the Git section in your project settings
- Under Ignored Build Step, add the following command:
git diff HEAD^ HEAD --quiet ./web
This checks whether anything in the web directory has changed. If not, the command exits cleanly and Vercel skips the build. If there are changes, the deployment continues as usual.
Option 2: Add it to vercel.json
If you prefer keeping everything in version control, you can add this to your vercel.json file:
{
"git": {
"deploymentEnabled": {
"main": false
}
},
"ignoreCommand": "git diff HEAD^ HEAD --quiet ./web"
}
This prevents the deployment from starting at all when there are no changes in the web folder, which means it won’t count against your deployment limits.
I have the Ignore Build Step option setup already and it seems to be working, but it still counts ignored builds towards my quota.
Resource is limited - try again in 2 hours (more than 100, code: "api-deployments-free-per-day").
I have the Root Directory set to web under Build and Deployment and have Ignored Build Step set to git diff HEAD^ HEAD --quiet – .. Ignored Build Step is relative to the Root Directory.
When i push a change somewhere that should be ignored it starts a deployment and then cancels it which seems to count as a deployment.
Root Directory Config #1
Root Directory Config #2
Ignored Build Step
I disconnected my github from vercel and ended up making my own vercel deploy github workflow. I don’t think there is a way to prevent deployments from triggering otherwise.
name: Vercel Deploy
on:
push:
branches:
- 'main'
paths:
- '.github/workflows/vercel-deploy.yaml'
- 'web/**'
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
jobs:
deploy-production:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy to Vercel
run: npx vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }}



