So I have got to the bottom of my confusion and I’m sharing it in case others get same or it helps improve the product. This has long confused me
So the root cause is that the GitHub integration adds behaviour not mirrored in the deployment settings. namely the builds are run not only commits to the production branch also commits to other branches that are the source branch in a PR merging to the Production branch.
So in this setup
- production branch: main
- dev branch in a PR merging to main: dev
- Branches setting - none (Deploy only the production branch)
Any commits to dev get a preview build. Even though we selected the options saying only commits to production! Confusing. It’s the GitHub integration adding behaviour.
The if I add a new branch called “suggest” with a PR to dev I want preview builds when that new branch is committed to.
By the above behaviour I should not need to say “suggest” is a branch I want commits to trigger builds. It’s the source branch of a PR. Hence my confusion. I’d expect to say “dev” branch should be built when PR source branches get commits.
But I see that only makes sense when GitHub integration is enabled, and the build settings panel doesn’t reflect that.
So is production branch special and it’s the only one that gets builds when it’s the target of a PR? Or can other branches be set up to do the same. Perhaps if the production branch setting only controls the target in a PR behaviour it can be renamed and take a list of branches to create preview builds for?
So, for now I’ll explicitly add the “suggest” branch as suggested by @coelmay even though that feels odd. And always we always have a PR for work so it is visible to the team, easy to see changes and allows discussion. Thus builds on commits to branches not in a PR are to be discouraged.