Hey folks,
Site name: well we have dozens but here’s an example one: soti-alpha
It is a static site (vue app + browser video game) that is built using TypeScript & Parcel.js.
We use dotenv paired with the NODE_ENV flag for environment variables per environment.
So in the repository we’ve got files like:
.env.local
.env.qa
.env.production
Which contain variables like:
(.env.local)
SOME_ENV_VAR=valueForLocal
(.env.qa)
SOME_ENV_VAR=valueForQA
(.env.production)
SOME_ENV_VAR=valueForProduction
And we want those variables to be different per environment when we build and deploy to Netlify.
In ~80% of builds that we do, this combination of tech all works fine! But in roughly ~1 in 5 deploys, it ends up picking the values from .env.local, so we’ll get a deployment to https://alpha.soti.io/ that has the website built with the value: valueForLocal
instead of the value it should have of valueForQA
(the value for the env var in .env.qa
for example, if the destination environment was QA).
I’ve had this recurring issue with Netlify for 2 years now (literally), but it’s been infrequent enough that I haven’t bothered to post about it. This week I decided I should
Our deployment process for these 2 years, in light of this bug, has been:
- Deploy
- Check if the env var bug is present (see if the deployment that just finished is using incorrect .env.local values)
- If no, do nothing - deployment successful
- If yes: boot up netlify, trigger a cache wipe deploy, and the issue will be resolved
This means some deploys (~1 in 5) necessitate a 2nd deploy, and will have a narrow window of time where the site is actually broken.
Am I missing something obvious? Any advice?