I have developed my own web server that does automation on my android app. If there are issues when the automation runs, I want to programmatically disable the "merge" button on a github pull request using a cURL REST command. I cannot find out the proper way to do this but it seems that many people would benefit from this functionality.
The api for github pull requests can be found here: https://developer.github.com/v3/pulls/
I know that this is possible because if you have merge conflicts on your branch, the button gets grayed out and you cannot click/merge it. That is the exact functionality I am looking for. Any help would be much appreciated.
This is possible. There are couple of steps you should take to enable this feature.
master
or/and develop
, depends on your workflow) as protected
.Pending
, Success
, Error
and Failure
statuses. Pending
,Error
and Failed
statuses will block Merge button.Once it's done you can POST statuses based on your business rules.
POST /repos/:owner/:repo/statuses/:sha
:sha
is the hash of the latest commit in the Pull Request
With payload like this one:
{
"state": "success",
"target_url": "https://link.to/some/repotring/page",
"description": "Automation tests passed!",
"context": "continuous-integration/automation-tests"
}
One thing is worth mentioning. When you have posted at least one status, the value from context
filed will be shown on the protected branch settings page. Don't forget to mark this status as required:
Protected branches and required status checks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With