I have my Production environment pointing at my main branch. I also have a staging environment (Pro plan enabled) that I also have pointing at my main branch. My Production environment is not on auto deploy on each change (i have to promote deployments to push to the production link) and my staging environment is on auto deploy. My Preview environment is set to all unassigned branches. Though when i push to main nothing is pushed to my staging environment and i see a preview for the main branch and Production: Staged which is the candidate for promotion.
I expect to see a candidate for promotion AND my staging environment deployment on each merge to main.
i just tried to change the configuration. if i set the domain from the environments page in my “staging” environment configuration it doesnt work. if i set the domain from the domains page it does work but automatically chooses the Production environment, which is not what i want. if i do the former and look at the domains page the domain is stuck on the Deploying status indefinitely probably because Vercel does not allow two environments pointing to the branch that Production uses.
to clarify for my business use case is, i want an environment that mirrors main but with different environment variables to point to a anonymized db with Neon and NeoSync. it is not helpful if i have to create a separate branch for staging since i need it as close to main as possible.
just tried to offload the branch syncing to GIthub.
now i have a github action that will sync staging with main whenever theres a push. the issue is that vercel detects the change in staging as a preview deployment only even though i have a configuration in my environments for staging which targets the staging branch and my preview environment says “all non specified branches” which should theoretically be main and staging.
Thanks for your patience If I understood correctly, I believe the issue you’re experiencing is due to how Vercel handles branch deployments and environment configurations.
Here’s what’s happening:
You can’t have two Production-type environments (Production and Staging) pointing to the same branch (main) because Vercel uses branch-based deployment logic to determine where to deploy changes.
For your use case of wanting a staging environment that mirrors production but with different environment variables, here’s the recommended approach:
Keep your Production environment pointing to main
Create a staging branch from main
Configure your Staging environment to point to the staging branch
Set up a GitHub Action to automatically sync your staging branch with main
What you’d need to do is to create a staging branch from your main branch and push it to GitHub. Then in Vercel, configure your Production environment to point to the main branch and your Staging environment to point to the staging branch, setting different environment variables for each. Finally, set up a GitHub Action (using the provided YAML configuration) that automatically syncs your staging branch with main whenever changes are pushed to main.
This makes sure your staging environment stays up-to-date with production while maintaining separate configurations and deployment URLs.