18

Is it possible to create a Github Check for pull requests? I know there are WebHooks, but is there a way to also hook into the UI?

Aim:

  • Pull Request made. Perform validation and update pull request if valid.

  • Pull Request merged. Create web call to URL. Update Github issue with confirmation.

What's the best way to do this? Is it only via Web Hooks, API calls and getting write oAuth credentials?

Ben Hall
  • 1,927
  • 5
  • 25
  • 39
  • What's wrong with the webhooks approach? – ceejayoz Aug 19 '16 at 16:24
  • The checks feel more consistent and in line with Github's UI. Webhooks + comments feels a bit like a workaround. If that's the recommended / accepted way then great, just want to make sure – Ben Hall Aug 19 '16 at 16:25
  • 2
    The status checks are available via the API. Get notified by a webhook that there's a PR, run your validation, and use the status API to update the GH issue with it. https://developer.github.com/v3/repos/statuses/ – ceejayoz Aug 19 '16 at 16:31

2 Answers2

12

Note: you now (August 2018) officially have the notion of Checks

When checks are set up in a repository, pull requests have a Checks tab where you can view detailed build output from status checks and rerun failed checks.

https://help.github.com/assets/images/help/pull_requests/checks.png

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    How does one setup checks in the repository? :) .. If want to do eslint check everytime someone pushes the code. How can one achieve it using checks? – Johnson Samuel Oct 11 '19 at 11:42
  • @johnsam One possibility, using GitHub Actions: https://github.com/features/actions (like https://github.com/gimenete/eslint-action) – VonC Oct 11 '19 at 11:51
  • @johnsam For checks: https://developer.github.com/apps/quickstart-guides/creating-ci-tests-with-the-checks-api/ – VonC Oct 11 '19 at 11:52
  • thanks for your reply. I did go through the links but couldnt get much on how to setup though there was info about what checks do and stuff like that. I did build bot using https://probot.github.io/ and I thought if it would be easy to integrate checks along with it. – Johnson Samuel Oct 11 '19 at 11:59
  • @johnsam Not sure how to combine the two (GitHub App and GitHub Action) indeed. You you ask that as a separate question. – VonC Oct 11 '19 at 12:09
8

I know there are WebHooks, but is there a way to also hook into the UI?

The recommended way of doing this is to use required status checks and the Status API, in combination with webhooks:

https://help.github.com/articles/about-required-status-checks/

https://developer.github.com/v3/repos/statuses/

Users set up required status checks on the repository so that merging a pull request is blocked if a specific status isn't success.

At the same time, webhooks trigger an external process when a pull request is updated, and that process creates statuses based on the output of that process. If the process completes successfully, then the process should create a success status which will be shown in the UI and unblock the merging of the pull request.

Is it only via Web Hooks, API calls and getting write oAuth credentials?

In order to create statuses, you will indeed need to authenticate with the credentials of a user that has push access to the repository (e.g. via a token from that user with the right scopes).

Ivan Zuzak
  • 18,068
  • 3
  • 69
  • 61