Running on GitHub Enterprise I have a small Jenkins job that looks for pull-request comments and triggers a script depending on the message.
Now I only want to trigger the script if review is already done from GitHub point of view, like all CODE_OWNERS and no additional person requested changes. I don't want to implement that logic myself. GitHub has different section for reviews and status checks. I only want review state, since I am going to set the status myself.
But I was not able to the correct value from the API endpoint. Neither from pull-request itself, nor from pulls/id/reviews.
Closest that i found was "mergeable_state", but this unfortunately takes the status check into consideration.
Is there another place to look for?
I don't think you can fetch the global review status. I think that the best you can do is to check that there are no review requests and fetch all reviews to check if there are no requested changes.
Finally we decided to make a Probot app in Github which was able to get all the required information.
Related
I need a way to get when a reviewer for a GitHub PR was requested using their API, but looking through the documentation there seems to be no way to do it. Is there any way that I can get the information I need?
If you want to be notified when a pull request review was requested, you can set up a webhook for the pull_request event. Then, you can listen for the review_requested and review_request_removed actions and do whatever you'd like in response.
Note that with GitHub webhooks, you will get all of the messages for a particular event, and you're responsible for filtering out the ones you want. GitHub doesn't provide filtering capabilities.
I started using https://github.com/manosim/gitify and I miss one thing: I don't get notifications when status check of Pull Request passed or failed. What's the easiest way to set it up? We don't use for project Github Actions/Workflows stuff.
I have not used gitify. Based on what I read, I suspect that these notifications are still set at the GitHub settings level. Essentially if GitHub triggers a notification for your account/organization, that is captured from gitify. Take a look at the notification menu page: https://github.com/settings/notifications
You can adjust your GitHub Actions notifications. If that doesn't work, then I'm not sure.
I am developing an automation tool that deals with GitHub pull requests and need to find the full list of GitHub pull request review statuses but couldn't get that either on its own API documentation page or generally on the web.
Those I've already found include APPROVED, CHANGES_REQUESTED, PENDING and DISMISSED. Appreciate if someone can provide me the full list.
This refers to GitHub Enterprise version of 2.12.
Check the list of available statuses in GraphQL API docs. There is the link. I'm pretty sure that other APIs (for instance, REST) also support and provide the same list.
There is a snippet from the documentation:
PullRequestReviewState
The possible states of a pull request review. Values
APPROVED
A review allowing the pull request to merge.
CHANGES_REQUESTED
A review blocking the pull request from merging.
COMMENTED
An informational review.
DISMISSED
A review that has been dismissed.
PENDING
A review that has not yet been submitted.
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.
Configure some of your branches (typically it's master or/and develop, depends on your workflow) as protected.
Using Statuses API you can send 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
Protecting the branch and then blocking merging if the status checks doesn't pass or reviews are not done works. This is a very straight solution and it works perfectly.
But if you are more curious then try doing it without protecting the branch. I could not find a way to do this.
I have 3 related github repos, with associated issue trackers. I'd like to get email when anything happens in the issues, but not whenever someone pushes, or makes a pull request. I don't see the ability to control notifications at this level of granularity.
I know that I can unsubscribe from specific threads, but that doesn't give me what I want either.
Alternatively, if there was a way to tell which type of notification it is in the email, so I can set up a filter, that would be fine too. However, I haven't been able to determine a consistent difference on that front either.
That's not possible currently using the features GitHub offers. However it may be possible using GitHub API.
I'd like to get email when anything happens in the issues, but not whenever someone pushes, or makes a pull request.
All Pull requests are issues but not all issues are Pull requests. That's being said, you cannot [currently] unsubscribe from pull requests and get the issues, since the pull requests are issues.
Since you are developer you can develop your own app to notify you (send you emails) when new issues are opened to specific projects.
Taking IonicaBizau/git-stats as example, you can access the issues like this:
https://api.github.com/repos/ionicabizau/git-stats/issues
You will get 304 Not Modified if there are no new issues. That way you can check if there were added new issues or not. Checking if the issue is pull request is done by checking if there is a pull_request field in the object, like mentioned here.
An alternative that I just found, is the Message-ID field of the email. the pull and merge emails all have <org/repo/pull/....> the issue emails have <org/repo/issue/....> so, I can filter on the Message-ID field.