Hey Netlify, I’m hoping you all could help me determine if Netlify would be able to support the developer experience I’m trying to create for future developers on my team. We’re very interested in Netlify for its front-end friendly workflows and seamless GitHub integration!
TLDR: Using a combination of Netlify’s environment variables, deploy contexts, and/or plugins, is it possible for Netlify to “know” a branch belongs to a certain user, and run a different build command accordingly? Here’s the full breakdown:
Our stack is pretty straightforward:
- Static javascript SPA built with Create React App
- Firebase instance for backend Storage, Cloud Functions, and Database
- Various other services, like Auth0 for authentication and SendGrid for email notifications
- …and hopefully Netlify for hosting and deploy/branch previews!
We imagine that upon each push to our master branch, Netlify will build our app with a command like this:
npm build && firebase deployTo production-firebase-instance
npm build
would package our static html/css/js bundle and throw the result on a fabulous Netlify url. firebase deployTo production-firebase-instance
would find the firebase code in our project and upload it to our Firebase instance, in this case, it’s called production-firebase-instance
.
With a Firebase instance reserved for production, we’d also like to provision Firebase instances for each contributing developer. Each developer on the team would then have their own Firebase sandbox, like sarah-firebase-instance
or david-firebase-instance
. This way as developers work, they can test code using their own sandbox firebase instance, instead of the production firebase instance. As developers work on their own branches, we’re imagining the following workflow:
- Developer Sarah creates a branch off of
master
calledadd-new-button
and pushes it to GitHub, triggering a Netlify build - Somehow knowing the
add-new-button
branch belongs to Sarah, Sarah’s push would runnpm build && firebase deployTo sarah-firebase-instance
instead of runningnpm build && firebase deployTo production-instance
- Later, when Sarah’s pull request is approved, her code, now merged into
master
, would trigger another Netlify build. This time, it will be built vianpm build && firebase deployTo production-firebase-instance
We thought perhaps all branch names other than master
could be prefixed with the developer’s name, and using that name, a build plugin might set a build command dynamically? In that case, a branch name in the format [name]-add-new-button
would build via npm build && firebase deployTo [name]-firebase-instance
.
What might be the most straightforward way to accomplish this?
I’d love your ideas!