Deploy Hook issue with Multiple Vercel Environments on Same Branch

Hi there!

I recently configured a custom “staging” Vercel deployment environment that deploys from the same branch as the “production” environment (both targeting the main branch).
We’re triggering a deploy hook daily, but I noticed that since adding the custom environment, only the staging deployment is being built.

Is there a way to ensure that both environments are built? Or to specify which environment should be built via the deploy hook? Or to make the “production” build the one with highest priority when a hook with multiple environments attached gets called?

Thanks, Klaas

1 Like

Hi, Klaas! Welcome to the Vercel Community :smile:

Thanks for reaching out about the deploy hook issue with multiple Vercel environments on the same branch. I appreciate you bringing this to our attention!

Here’s what’s happening:

Vercel has a specific behavior when it comes to multiple environments (like production and staging) pointing to the same branch. To prevent deployment conflicts, Vercel only allows automatic deployments for one environment per branch, typically the production environment . This is why you’re experiencing issues with deploy hooks for your additional environments.

To resolve this, you have a few options:

  1. Use separate branches for different environments (recommended):
    Create a ‘staging’ branch and point your staging environment to it. This way, both environments can have their own deploy hooks.

  2. Implement a custom CI/CD pipeline:
    Use GitHub Actions or another CI tool to manage your deployments. You can set up a workflow that triggers the appropriate deploy hooks in the order you need.

  3. Vercel’s promotion workflow:
    Deploy to one environment first (e.g., staging) and then use Vercel’s promotion feature to promote to other environments (e.g., production) . This allows you to maintain control over the deployment process.

  4. Manual deployments for non-production environments:
    While not ideal for automation, you could manually trigger deployments for your staging environment using the Vercel dashboard or CLI.

Recommended documentation
  1. Vercel Environments Overview:
    https://vercel.com/docs/concepts/projects/environment-variables#environments
  2. Vercel Deployment Overview:
    https://vercel.com/docs/concepts/deployments/overview
  3. Git Branch and Environment Relationship:
    https://vercel.com/docs/concepts/git/vercel-for-github#branch-organization
  4. Creating and Managing Deploy Hooks:
    https://vercel.com/docs/concepts/deployments/deploy-hooks
  5. Promoting Deployments (for environment promotion workflow):
    https://vercel.com/docs/concepts/deployments/promoting-deployments
  6. Vercel CLI for Manual Deployments:
    https://vercel.com/docs/cli
  7. Environment Variables and Secrets:
    https://vercel.com/docs/concepts/projects/environment-variables
  8. Vercel for GitHub (or GitLab/Bitbucket) Integration:
    https://vercel.com/docs/concepts/git

Happy Christmas Eve :santa:

Hi Pauline, thanks for your reply!

Vercel only allows automatic deployments for one environment per branch, typically the production environment

Understood - but isn’t it a bug that, in our case, the staging environment apparently takes precedence over the production environment?

(We’ve also enabled the “Prioritize Production Builds” but that doesn’t seem to be related to this)

Hi Pauline - I just wanted to follow up on my latest question in case it got overlooked :slight_smile:

Thanks, Klaas

Another gentle reminder :slight_smile: Is it perhaps better to reach out to Vercel support?

Hi @klaasman, I believe I fixed the issue. Can you try the deploy hook again and let me know if it is working as expected? Thanks!

2 Likes

Hi Cody - You’re right! As of this morning our daily deploy hook triggered the production build :partying_face: (or actually it triggered both environments that build from the main branch - perfect!)

Thanks – Klaas

2 Likes

Appreciate your patience with this! Let us know if we can help with anything else :wave: See you around the community :smile:

1 Like

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