自动合并经过验证和测试的GitHub合并请求 [英] Automatically merge verified and tested GitHub Pull Requests

查看:892
本文介绍了自动合并经过验证和测试的GitHub合并请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动(即来自Jenkins)合并经人员批准且已成功测试的GitHub拉取请求;换句话说,当这些复选标记的所有三个都是绿色时:



这可能吗?我还没有找到关于GitHub的新已批准变更代码审查功能的API的任何文档。 有一个新的 PullRequestReviewEvent webhook 当审核以非待决状态提交时触发。 webhook的主体包含 [review] [state] 字段,当> approved 时所有的评论者都已经批准了这些修改(例如,当你在界面中得到绿色已批准修改的勾号时)。

结合 StatusEvent 为您的拉动请求的头部SHA从CI等等获取状态检查,然后最后通过向API请求拉取请求

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

一旦你有了所有三件事情,你可以合并请求与:

  PUT /回购/:所有者/:回购/​​拉/ /编号/ mer ge 

和适当的有效负载参数。请注意,您需要 Accept:application / vnd.github.polaris-preview + json 来处理某些有效负载参数,因为它们处于预览期间。


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 these checkmarks are green:

Is this possible? I haven't found any documentation on an API for GitHub's new "changes approved" code review functionality.

解决方案

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.

这篇关于自动合并经过验证和测试的GitHub合并请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆