It would be great to be able to do “branch deploys” and “deploy previews” from the CLI or API. For example I want to use Gitlab CI to build and test my site for flexibility however due to the lack of fixed deploy URL I can’t use Netlify as a review app. If I could manually specify the “branch name” on the CLI/API then I could simply deploy from there.
Something like netlify deploy --branch=$CI_COMMIT_REF_NAME. Then the URL is predictable so you can include it in the url parameter of the review app configuration. Or even better I would use $CI_COMMIT_SHA so that I can easily see the website for any git version.
@kevincox I have setup a build hook to build a preview off a specific branch that uses headless data. You can read about build hooks here. It will get you most of the way to what you want in the short term.
The ask: I’d love to be able to trigger builds based on changes in other GitHub repos than the one that contains my site, and filter out the branch so it only builds when a specific branch changes.
You can have a fixed deploy URL for any (set of) deploy(s). You’d create several sites, one per branch, and set a name for each, then you could access latest netlify deploy --prod for each “environment” by steady name!
Indeed the CLI has no plans to add context like that since that concept of branches and contexts is intrinsic to our build system and git, and not just uploading a site. I understand that in your case it does make sense, but this is not the usual use of the CLI so we aim for one-size-fits-most there
The problem is that multiple sites don’t work for dynamic branch names. In fact, right now in my “custom” solution I deploy every commit to its own URL so that I can compare any two versions at $[commit.mydomain.com](http://commit.mydomain.com). I don’t think making a new Netlify site for each commit will work.
It doesn’t have to be tied to branches. You can call the flag --name. But the fact remains that having predictable and stable URLs is very useful for development. I can send a coworker a staging link which I can then update (but using the same “name”) and which doesn’t conflict with anyone elses deploys.
Without this you are forced to use Netlify’s very basic CI or lose most of the feature set. If this feature was added then you can focus on the deploy and CDN and let CI tools focus on the CI features. How it stands now the functionality is crippled.
It’d be great to be able to cleanup/delete previous builds. Like being able to setup a hook so that when a branch is deleted/MR merged the old builds get removed.