Would it be possible to have one branch do multiple deploys?
For example: Netlify is linked to a Github repo. All code is merged into the master branch of that repo. The Netlify config for that repo has two different URLs - example.com and either staging.example.com or just use a consistent netlify url for staging.
The deploys to the main site can be locked just like normal, but the deploys to the staging branch are continuous.
Why?
All code is merged to master, reducing merge conflicts and reducing the need for a persistent staging branch (which usually then has to get merged into master later on to deploy)
The staging branch+website is always the latest code, greatly simplifying QAsā jobs by not having n number of different netlify deploys to go look at, and devsā jobs by integrating sooner with other devās code
Deploys to prod website can be manual (by unlocking the deploy and then locking again)
Thoughts?
[edit] from a very naive perspective, it seems that netlify maybe already has the core functionality to enable this, it would just be rearranging it in a different way. But software is hardly ever that easy
But this would be a huge boon to devs/companies that do trunk-based development, which currently with netlify is a pain and a blocker in many ways. Weāve considered moving off of netlify because of the difficulty of trying to get a good trunk-based development workflow going.
We try not to judge folksā workflows; I trust you have a reason for wanting what you want
Trunk-based development isnāt some strange idea, itās quite popular and common.
Itās a workflow that Netlify just doesnāt really support that well, and Iām hoping that my suggested changes make the support a lot better.
I think what trunk-based devs are doing currently is just building elsewhere and then using the Netlify CLI to upload to various sites. Again, not ideal, and it could be so much better if Netlify supported this workflow directly.
You can link as many sites as you like to the same repo, put different names and different configs on them, even if you build the same branch.
Thanks, Iāll try this for the moment. Itās just not ideal to have two different places that I have to manage website config/settings.
An issue Iām running into implementing this workaroud, though, is that the deploy context for both sites is production but thatās not what I want it to be for my staging website. (E.g. weāre using a netlify.toml file with different contexts to determine which API backend to hit. But if both the āstagingā website and the āproductionā website have the production context, theyāre both hitting production APIs.)
Is there a way to change the context, or is it always just determined by the main branch? I wasnāt able to find anything concrete in the docs. But I could have missed something?
If not, then I think my next best bet is to just pull deploys out of Netlify and do them somewhere else (e.g. CircleCI) and then upload the built files to separate Netlify websites? (alternatively, I can change those to run-time variables as well)
Trunk-based development isnāt some strange idea, itās quite popular and common.
Sure, I wasnāt trying to say it was weird, just that we donāt judge and try to enable you.
On second reading of your initial request, as far as I can tell, what you have asked for is the default:
locked deploys prevent production content from changing
but have no impact on branch deploys.
Were you seeing something different?
I had initially thought you wanted to lock the staging branch deploy was why I gave you that advice, but I am no longer confident in either read after going over it a few times.
Iām not sure if weāre on the same page; let me try to explain in a different way what I would like to achieve:
I probably wouldnāt use branch deploys - branches are short lived (e.g. hours or a couple days at most) so it probably isnāt worth it
All code is merged directly to master branch.
Master branch deploys to two (or more? I would probably only use 2 to start, but I have used 3 at various places) different sites:
a āstageā website. This website is always deployed/updated when code is merged to master
a āprodā website. This website deployment is ālockedā, and then can be āunlockedā when weāre ready to ādeploy to prodā. We can then lock it again afterwards
Both the stage and prod website are managed in a single website config, since really itās the same repo and even same branch - the only difference is which specific commit has been deployed.
This workflow better matches how trunk-based development generally works, and would improve trunk-based workflows significantly.
Does this help? Let me know if it still doesnāt make sense. Thanks!
I guess I am not understanding what is not possible in that workflow with our existing tooling:
you configure your repo with a netlify.toml that will apply for the 2 sites you link it to. It sets things like environment variables, build command, etc.
on the stage site, you have us build every commit automatically. You can see work in progress at reliable URLās like feat-1234āmystagesite.netlify.app, and you can see the production build at its URL which you could either set a sitename like ābeta.yourdomain.comā for, or use the netlify site directly (https://yourstagingsite.netlify.app).
on the prod site, you have deploys either turned off completely or instead use the locked deploy feature to prevent unwanted publishes. Youād also have builds for all non-production branches turned off, since you donāt need to see a second copy of those builds on the short lived branches on this second site.
Does that sound feasible, and if not, what feels bad about it?
I would love the documentation for Functions to be clearer, especially for those who are new to the concept. Thereās a smattering of information on the internet, but itās hard to tell what is outdated and what doesnāt work. I still donāt know whether to use netlify-build or the build process or what the real difference is. Simple examples would really help - using CRA, using Express, accessing files within a lambda function, etc.
not having the ability to change settings for both websites at the same time
the netlify.toml sees both websites as āproductionā so itās difficult to have different settings/environment variables since theyāre both considered āproductionā
I think 1) isnāt a big deal, but would be an improvement, but 2) is a big deal and will require me to reconfigure quite a bit to get things to work in this setup. I think it can be done, itās just not easy nor ideal.
Ah, thanks for clarifying! I donāt have a good workaround for #2 except doing something conditionally in your build script based on site name or site ID, not exactly an easy pattern, since youād also have to create something for local dev to work. If you only had different branchnames, (staging used a staging branch), you could set branch-specific contexts like [context.master] and [context.staging]. But then we also wouldnāt be talking
I donāt understand what settings you are making per website, outside of netlify.toml that you need to make in two places - could you elaborate? Perhaps it is possible to set them all there and at least remove the #1 problem.
I donāt understand what settings you are making per website, outside of netlify.toml that you need to make in two places - could you elaborate? Perhaps it is possible to set them all there and at least remove the #1 problem.
Just pretty much anything that is configured through the Netlify website itself, e.g. environment variables, notifications, etc. Nothing major though.
environment variables can be configured in netlify.toml (probably only useful if not sensitive; I donāt like committing e.g. my ssh key to the repo!):
I am currently using the build ignore feature with a monorepo quite heavily. I also happen to use slack webhooks to notify my team about successful and failed builds.
What I really wish for at this moment, is to differentiate between failed builds and cancelled builds.
I get reports of a failed build in slack every time a build is cancelled, though I see the cancelled tag in netlify itself. Iād love for that to be reflected in the webhook message sent to slack as well.
Netlify already has great DNS support, and one makes it very easy to provision SSL certs.
My ask is to augment the Netlify DNS feature to allow us to define our DNS zone records (A, CNAME, ALIAS) as code in our repo. This would allow us to manage our DNS as code.
Related to this: Iād love a distinct message type for cancelled builds that can subscribed to, so that we can opt in to notifications for cancelled builds the same way we currently can for successful or failed builds.
I played a bit with asset optimization and security headers/features. Iāve noticed assets optimized are missing subresource integrity. Iād love to have SRI by default on optimized assets.
Hi Luke! Any chance you could publish an update regarding this āDeployable Naming Conventionā feat? Itās quite of an stopper for us right now. Thanks!!