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 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:
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.
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.
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.
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.
Hi Cody - You’re right! As of this morning our daily deploy hook triggered the production build (or actually it triggered both environments that build from the main branch - perfect!)