We have static react site deployed with Heroku pipelines.
The code is pushed and build automatically on Stage. For pushing to Production, we would like to use the Heroku promote function, so we are sure we use the same build we tested on stage.
Stage and Production have different APIs we would like to configure via Heroku's environment vars.
During the npm run build
on Stage const apiUrl = process.env.API_URL
is replaced during with const apiUrl = "https://stage-api.example.com"
Unfortunately (but of course), after promoting to Production the apiUrl
is still the one from Stage.
Also, a hack with the release phase does not work, because filesystem changes during the release phase will not be deployed.
Is there a way to use Heroku's promote function with a static build together with Environment variables (I know we could do a rebuild per stage or load a config based on the domain)?
Any good practices to deploy a static site with Heroku pipelines?