Can I create both staging and production deploy context from master


I am evaluating Netlify to host a react application. I would like create two environments, “staging” and “production” both deployed from the master branch of the Git repo.

I read through the deploy context documentation and it appears that for the production environment, I can specify a branch to deploy from (and I can use the master).

But for the staging environment, my only option is to use branch deploy context which deploys from a branch but not the master.

Is my understanding correct that I can’t create staging environment from the master and I must use another branch for this purpose?



Yes, you’d need a different branch. While you can technically use your master branch for a staging build (details below), you can’t deploy production as well as staging using the exact same code.

You can probably force Netlify’s context using:

  context = "staging"
  # settings

But as you can see, the same file would also be used during the master deploy, and thus, even if you connect same repo to 2 different websites and publish it, they’ll end up using the same context.

This is all without me trying it out, so it might be slightly off.

Hi, @vineetdigit. You can create two different sites, both connected to the master branch. You could then call one site my-site-staging and the other my-site-production. The two site can have different setting in the web app UI (but not in netlify.toml).

However, there is still the issue of a shared netlify.toml file. If you require different settings for the two sites, hopefully they are settings that can be changed in the web UI. I say this because I don’t have a way for you to use two different netlify.toml files for the same branch.

If there are other questions, please let us know.

Ok, thanks Hrishikesh. Appreciate your response.

Thanks Luke. I am hoping that shared netlify.toml should work. I will experiment with these recommendations. Appreciate your response.

1 Like

Building off of previous replies:

Is there a workaround / approach to have two different sites (staging and production) using the same branch, with separate context-configurations for each?

As long as you don’t need seperate settings in netlify.toml, you can do it. Even if you need to change one line of that file in the 2 deploys, you’d have to use a different branch.