Multiple Branch Deploys for one Branch

We have a case where we need to have two separate branch deploys for one branch.

In github we have a branch called staging and whenever we push to this branch we need to deploy two different sites:

  • staging–mycompany.netlify.app
  • staging-regression–mycompany.netlify.app

These two sites are to use the same code on the staging branch but with different environmental context basically. This is for regression testing purposes, enabling automated e2e tests to validate the code on staging using two sets of feature flags.

Recommended approach to have two deploys for a single branch?

Hi, @jmurphy-res. I would recommend linking the repo and branch to two different sites. This would cause the commits pushed to that upstream branch to trigger builds on both sites and you could configure them each independently.

@luke
Thanks, that’s something I didn’t think of and is very likely the simplest approach.

One consideration…
We have a lot of .env variables configured in the Netlify UI at the site level. Probably too many to manually sync up between the proposed Website A and Website B.

We might be able to keep Website B empty of env config and write a build plugin to get the .env vars from Site A using the API.

Thoughts?

If using the same branch is absolutely necessary then I suppose you could use a plugin and the Netlify API to achieve this. Note that, using this method, the environment variables would only be available during the build time. So if you need them in the server-side functionality, that won’t be possible.