如何为打开,编辑或合并拉取请求配置触发CodePipeline?
这是一个Terraform配置:
resource "aws_codepipeline_webhook" "gh_to_codepipeline_integration" {
name = "gh_to_codepipeline_integration"
authentication = "GITHUB_HMAC"
target_action = "Source"
target_pipeline = aws_codepipeline.mycodepipeline.name
authentication_configuration {
secret_token = var.github_webhook_secret
}
// accept pull requests
// Is there a way to filter on the PR being closed and merged? This isn't it...
filter {
json_path = "$.action"
match_equals = "closed"
}
}
CodePipeline设置为接受具有在过滤器中指定的所有条件的Webhook事件,该条件对应于Pull Request Events。
请注意,GitHub文档声明了action
的{{1}}字段(我的重点是粗体):
已执行的操作。可以是已分配,未分配, review_requested,review_request_removed,已标记,未标记,已打开, 编辑,关闭,ready_for_review,锁定,解锁或重新打开。如果 操作已关闭且合并键为假,提取请求为 用未合并的提交关闭。 如果该操作已关闭且已合并 键为true,则合并了合并请求。 同步拉取请求时触发,Events API时间轴 不要在同步动作中包含拉取请求事件。
似乎我需要对PullRequestEvent
&& $.action==closed
都进行过滤,但看起来我不能同时进行过滤。如果仅对$.pull_request_merged=true
进行过滤,则如果PR不合并而关闭,则管道将重建。这是我的疏忽吗,还是CodePipelines在触发方面不如CodeBuild项目灵活?