Automatically merge verified and tested GitHub Pull Requests

前端 未结 6 1216
醉话见心
醉话见心 2021-02-04 11:42

I\'d like to automatically (i.e. from Jenkins) merge a GitHub pull request that has been approved by a person and has been tested successfully; in other words, when all THREE of

6条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 12:11

    There is a new PullRequestReviewEvent webhook that is triggered when a review is submitted in a non-pending state. The body of the webhook contains the ["review"]["state"] field, which will be approved when all reviewers have approved the changes (i.e. when you get the green "changes approved" tick in the UI).

    Combine this with the StatusEvent for the head SHA of your pull request to get the status checks from CI and so on, then finally check the "merge-ability" of the pull by requesting the pull request from the API:

    GET /repos/:owner/:repo/pulls/:number
    

    Once you have all three things, you can merge the pull request with:

    PUT /repos/:owner/:repo/pulls/:number/merge
    

    and appropriate payload parameters. Note you'll need the Accept: application/vnd.github.polaris-preview+json for some of the payload parameters as they are in a preview period.

提交回复
热议问题