Open zeke opened 6 years ago
@gr2m suggested that there might currently be some roadblocks for such a bot: https://platform.github.community/t/repositories-which-have-protected-branches-with-push-restrictions-have-no-ability-to-grant-push-rights-to-integrations/1376
we're thinking about doing something similar for Angular, we already have a probot app that checks if the PR is good to merge, but it doesn't do the merge itself yet
Hey @ocombe is that bot source public?
yes! it's here: https://github.com/angular/github-robot we're going to add some new PR triage functionalities soon as well, see https://github.com/angular/angular/issues/21884 for a first draft of what we intend to do
GitHubContribute to github-robot development by creating an account on GitHub.
Good stuff. Thanks for sharing, @ocombe.
I seen https://github.com/angular/angular/issues/21884. I know to work with github api's but no working experience for bot in github.
I would like to work on this any suggestions on how the bot should behave if the mentioned issue where bots not being able to merge pull requests with protected branches
So I went through this https://platform.github.community/t/repositories-which-have-protected-branches-with-push-restrictions-have-no-ability-to-grant-push-rights-to-integrations/1376
.
And it doesn't look like GitHub has released a fix yet.
Further AFAIK there is no realistic workaround for this?
Can anyone give some idea so as to how we might go about this?
I don't think that an app should be able to bypass protected branches. Those are typically very sensitive branches where things would break if merged incorrectly, and I think that folks would be upset to see an app ignore their intentional decision to treat that branch more carefully.
Protected branches refer to branches with some restriction on who can push to the branch. Isn't that the case for most branches?
@JasonEtco it’s not about working around protected branches, it's about automated merging once all the checks are green
it’s not about working around protected branches, it's about automated merging once all the checks are green
I see - I guess it depends on the level of protection (which is ultimately up to the user). One available option is the only allow merges with at least 1 green review from someone with write access; I think that as long as that protection isn't ignored then its all good. I only bring it up because I'm not sure if that's considered a "status."
Sadly the GitHub API doesn't support GitHub apps merging pull requests with protected branches yet. @JasonEtco
GitHub API doesn't support GitHub apps merging pull requests with protected branches yet.
I found the internal GitHub issue for this and gave it a little bump. It's a known issue, GitHubbers are aware that integrators are frustrated by it, and a solution is actively being discussed. I'll report back here with any updates.
@zeke That's awesome.Thanks
@zeke I would like to work on this. I have completed hello-world bot. What's the next step?
@pranay414 GitHub folks are actively working on a fix for the bot permissions problem, but it hasn't shipped yet. I will post here when that happens.
@zeke so should I start drafting a proposal for this?
@pranay414 sure. If you want to outline the expected behavior that could be helpful.
@zeke when someone submits a PR then it is put into testing and once all checks are passed then it should be merged or it should be reviewed by someone and then merged?
@pranay414 One of the status checks will probably be getting the PR reviewed.
@rsarky so once it is reviewed then it should be merged right?
@pranay414 Once all the status checks pass. The status checks may include CI, reviews etc.
Ok got it, Thanks :)
@gr2m @JasonEtco I would like to consider this for my GSoC proposal. Can you please guide me how do I proceed?
@gr2m @JasonEtco . I have given this task a try and it works for ci-validated and mergeable PRs. Please find my repository here gsoc_probot_task_1
@zeke A new API endpoint is now available and it is perfect for this use case :tada: Merge PR
@rsarky you beat me to it! Thanks to @kytrinyx for helping move this forward.
i'm not sure how helpful any of this is to this thread, but i figure its related enough to at least mention. i maintain greenkeeper-keeper that serves a very similar purpose, but is purposely limited to PRs that are from greenkeeper. the current implementation is a hapi plugin, but a probot version is on my list even though i haven't found time to make that happen yet. i'm very interested in where this goes as i could see potentially replacing greenkeeper-keeper
with this.
one thing that might be worth considering is the ability to limit the automatic merge to a certain type of PR. the important detail for greenkeeper-keeper
is that it is limited to only greenkeeper PRs. they are only dependency upgrades, so there isnt anything to review beyond passing commit checks. contributions from humans usually are more more worth a human review, so my team likes to handle those differently.
I almost never want to merge pull requests unseen as soon as they pass—it's almost always a thing where I've reviewed it, and want to merge it, but the build is still running, so I go look at instagram and check my email and completely forget what I was actually doing. That's when I would want to have a way to signal to a bot: go ahead and merge this as soon as it passes.
I could see this working with protected branches that have required builds and require an approval from a human reviewer. Then as soon as all the requirements are met, it could merge it.
I've been working on a probot that does exactly this the last few days. It is working for the tests I've done with it, but I still consider it experimental. Let me know what you think: https://github.com/bobvanderlinden/probot-auto-merge
GitHubprobot-auto-merge - A GitHub App built with Probot that automatically merges pull requests
Thanks for sharing, @bobvanderlinden!
The Electron team has been experimenting with @dependabot, which has a feature for auto-merging dependency updates when checks pass: https://twitter.com/dependabot/status/1015290676081283072
“Cheeky little feature: you can now set your Dependabot auto-merge strategy to "in-range updates" and it will automerge any dependency updates that satisfy the range in your Gemfile / package.json / cargo.toml / Pipfile / composer.json / mix.exs 🍸”
I was meaning to check out Dependabot, but mostly for its automatic dependency updates. Does it do automatic merges for pull requests in general? Then I might want to look into that too.
Does it do automatic merges for pull requests in general?
No. Just for its own PRs.
I feel you @kytrinyx. This is where Mergify is actually very helpful, since it does provide this auto-merge feature when CI is passed as a base feature. :)
Anything on this in 2019? 👍
Thanks to some work from @kytrinyx late last year, there's now an API endpoint for merging PRs: https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
@dependabot already has support for this, and the product was acquired by GitHub earlier this year. If you want this functionality today, you can install @dependabot on your projects. As for the future of this becoming a feature built into GitHub itself, I am not sure.
GitHub DeveloperGet started with one of our guides, or jump straight into the API documentation.
Quite a few people are now using https://github.com/bobvanderlinden/probot-auto-merge. I do not consider it experimental anymore. I personally use dependabot as well as probot-auto-merge. They both have their purposes.
For example, for some projects it's fine to just approve prs with a review and have it automatically merged. For other projects merging to master happens in batches: I label all approved prs with a merge label and merge them all. Probot-auto-merge works fine for those usecases.
Dependabot is great for automatically merging using a comment or a development dependency update. It just doesn't do more complex merging rules.
GitHubA GitHub App built with Probot that automatically merges pull requests - bobvanderlinden/probot-auto-merge
https://github.com/fossapps/MergeWhenReady I also gave this a try, it doesn't use any config, you protect your branch with everything you have from github (require review, status checks etc), once the button becomes green, and IF you have added a label created by this bot, it automatically merges the branch
GitHubContribute to fossapps/MergeWhenReady development by creating an account on GitHub.
In this twitter thread are a few more of these: https://twitter.com/rauchg/status/1154190143013584898
https://github.com/chdsbd/kodiak#prior-art has a matrix of some auto-merge bots and their characteristics.
“We installed a GitHub bot that automatically merges PRs to master when certain conditions are met … which in turns deploys to prod domain with @zeithq … which is a dream come true https://t.co/K9Jr3oc7ba 🚢”
GitHub🔮 A bot to automatically update and merge GitHub PRs - chdsbd/kodiak
the one I did is very basic, if there's a label and PR can be merged it merges it. It's typescript automatically deployed to now.sh and it automatically deploys to docker hub as well, so if you want to run your own instance, you can. :)
http://reporanger.com also handles this 🙂 Very biased, since I built it, but let me know if anyone needs help setting it up or configuring a specific automation 👍
Ranger is a sidekick for GitHub maintainers.
it's almost always a thing where I've reviewed it, and want to merge it, but the build is still running, so I go look at instagram and check my email and completely forget what I was actually doing. That's when I would want to have a way to signal to a bot: go ahead and merge this as soon as it passes.
My team has settled on using https://github.com/pascalgn/automerge-action for this workflow. Attach an automerge
label to the pull request and walk away (or go look at Instagram). Once it turns green it will get merged.
GitHubGitHub action to automatically merge pull requests that are ready - pascalgn/automerge-action
My team has settled on using https://github.com/pascalgn/automerge-action for this workflow. Attach an
automerge
label to the pull request and walk away (or go look at Instagram). Once it turns green it will get merged.
That's exactly what Mergery does too. One of the reasons I wrote it is that the configuration for automerge-action
was quite bewildering, and it didn't work as expected when I tried it. Mergery doesn't require any config, it works with the default repository config, and it's fast :-)
https://github.com/fossapps/MergeWhenReady I also have this, however installation had some issue, however people say it's working for them, so not sure what's going on. When you label a PR with a specific value, it waits for status checks to pass and it merges the PR.
GitHubContribute to fossapps/MergeWhenReady development by creating an account on GitHub.
You can also checkout MergeQueue for not just auto-merging, but also avoid all the build conflicts. It also works on Github labels. Read the docs for details.
Ooh, MergeQueue sounds very promising! 👍 Like dependabot and pullreminder, this sounds like an application that fills the gap in GitHubs core functionality. Thanks for bringing it up.
For some projects (with really good test coverage?) it would be cool to have a bot that automatically merges any PR that has passing status checks, e.g. tests passing, reviews approved, etc.
If this existed, we would probably use it on the Electron website: https://github.com/electron/electronjs.org/issues/1046