voorhoede / head-start

Base setup on top of headless services to help you quickly start a new website
ISC License
3 stars 0 forks source link

Move DatoCMS environment variables into .env file #106

Closed phortuin closed 8 months ago

phortuin commented 9 months ago

While setting up a new project based on Head Start, I was being griefed by the datocms-environment.ts file. It was set to an environment that did not exist in my clean DatoCMS set up and the build trigger ID was not set up either. To me it seems both values fit perfectly well in a .env file and avoid issues while using Head Start as a template for new projects. The filename (datocms-environment) already gives away its use and there are .env files for that.

Proposed solution

Move datocmsEnvironment and datocmsBuildTriggerId out of datocms-environment.ts and into .env vars.

jbmoelker commented 9 months ago

We need to be able to differentiate datocmsEnviroment between branch deploys, so that PR previews can use a DatoCMS sandbox environment. Unfortunately we can't set an env variable per branch in Cloudflare Pages (unlike Netlify and Vercel can since recently). And when a PR is merged that sandbox environment should also be promoted to the main DatoCMS environment. The main branch is now automatically connected to the right DatoCMS environment on merge. We can solve this by automating migrations on merge. But that's also still blocked by #62 .

The datocmsBuildTriggerId could be moved to .env. It's not really a secret, but I agree it's a bit of a random value which we could move to the .env. Just means we have to configure it in more places, and it makes it a bit harder to use a different value in a specific branch deploy (as explained above).

Since this motivation isn't really intuitive, should we add a decision log entry on it and refer to that from datocms-environment.ts and docs/getting-started.md?