Vercel custom environments: Disabling preview checks on GitHub

I have a project that has the following environment setup:

  • Production - main branch gets deployed on push
  • Staging (custom environment) - staging branch gets deployed on push
  • Preview - branch tracking disabled, no preview deployments

We have preview deployments disabled due to our unique database structure which doesn’t allow for database branching via Vercel. We plan to work around this by using GitHub CI instead of Vercel CI, but that’s later down the road.

The problem is that whenever I have a pull request on a branch that’s not main or staging, the Vercel bot marks the deploy as failed with the error Preview deployments are disabled for this project.

This is fine, but it’s kind of annoying to see checks failing when deployment shouldn’t even be a check:

Is there a way around this at all?

Hi Kyle,

I understand your frustration with the failing checks on branches that aren’t supposed to be deployed. Thank you for the detail :pray:

Could you try the following?

Create a vercel.json file in the root of your project with the following configuration:

{
  "git": {
    "deploymentEnabled": {
      "main": true,
      "staging": true
    }
  },
  "github": {
    "enabled": true,
    "silent": true
  }
}

This:

  1. Enables deployments only for the main and staging branches
  2. Implicitly disables deployments for all other branches
  3. Keeps the GitHub integration enabled but silences the deployment status checks
  • By only specifying main and staging in the deploymentEnabled object, Vercel automatically disables deployments for all other branches.
  • The "silent": true setting in the GitHub configuration prevents Vercel from creating status checks for deployments, which should resolve the issue of seeing failed checks in your pull requests.
  • The configuration will prevent the “Preview deployments are disabled for this project” error from appearing as a failed check in your GitHub pull requests.

You can also manage these settings through the Vercel dashboard:

  1. Go to your project settings
  2. Navigate to the Git section
  3. Under “Production Branch”, set it to “main”
  4. Under “Custom Domains”, ensure your staging branch is properly configured
  5. Under “Preview Deployments”, you can disable them entirely if you prefer a UI approach

Let us know how you get on!

Haven’t had the chance to run a main or staging deploy, but for a separate branch PR:

  1. Branch was pushed and PR was made at 7:22pm, no Vercel bot checks were made
  2. At 7:47pm, Vercel bot comments: Deployment failed with the following error: Creating the Deployment Timed Out.
  3. PR check has Vercel failing with Deployment failed.

I’m in a turborepo monorepo so my vercel.json is in /apps/web

{
  "regions": ["sfo1"],
  "git": {
    "deploymentEnabled": {
      "main": true,
      "staging": true
    }
  },
  "github": {
    "enabled": true,
    "silent": true
  }
}

This is only in the feature/PR branch, not main or staging.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.