以便接受一个拉取请求时

以便接受一个拉取请求时

本文介绍了创建一个GitHub webhook,以便接受一个拉取请求时&合并为主的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个webhook,当前在任何分支上触发 push 。这太频繁地触发webhook。理想情况下,webhook只会在拉取请求合并 master 时触发。虽然我没有看到这个选项,但是:


有没有办法获得额外的webhook选项或以某种方式定制webhook?



为此,请确保您的脚本对。要测试的条件包括:


  • 操作为关闭

  • 合并(在pull_request中)是 true



忽略在合并请求中发生任何其他活动(包括未合并关闭)时收到的所有ping。


I have a webhook that currently fires on push to any branch. This triggers the webhook far too frequently. Ideally, the webhook would only fire when a pull request is merged into master. I don't see that as an option, though:

Is there a way to get additional webhook options or to customize the webhook somehow?

解决方案

So, you can't customize the conditions of the trigger, but as LeGec mentions you can customize your code to only trigger when the Pull Request is merged.

To do that, make sure your script responds to the PullRequestEvent. The conditions to test are:

  • "action" is "closed"
  • "merged" (inside of "pull_request") is true

This way your script can ignore all the pings it receives when any other activity occurs on the Pull Request (including closing without merging).

这篇关于创建一个GitHub webhook,以便接受一个拉取请求时&合并为主的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 20:43