简体   繁体   English

GitHub 为代码审查拉取请求创建操作分支

[英]GitHub action branch creation for code review pull request

I'm trying to create a GitHub workflow that will run ONLY when a new branch is created with a pattern.我正在尝试创建一个 GitHub 工作流,该工作流仅在使用模式创建新分支时运行。 The purpose of this is to create a Code Review Pull Request when a new branch is pushed to origin, but only on the first time the branch is created, so using a push event will not work and why I'm looking at create .这样做的目的是在将新分支推送到源时创建代码审查拉取请求,但仅在第一次创建分支时创建,因此使用push事件将不起作用以及我为什么要查看create

All of these combinations fail where any new branch created will run, instead of those just matching the pattern所有这些组合都在创建的任何新分支将运行的地方失败,而不是那些只匹配模式的组合

name: "Create Code Review PR"

on: 
  create:
    branches: ['feature/**']      

or或者

name: "Create Code Reivew PR"

on:
  create:
    branches:
      - 'feature/**'
      - 'support/**'
      - 'hotfix/**'

In both of these scenarios, if push a new branch called no-code-review , the above workflow will still run, but my expected behavior is that it wont run, but it should when a new branch such as these: feature/new-branch , support/new-support-branch or hotfix/fix-this ONLY.在这两种情况下,如果推送一个名为no-code-review的新分支,上述工作流程仍将运行,但我的预期行为是它不会运行,但当新分支如下所示时它应该运行: feature/new-branchsupport/new-support-branchhotfix/fix-this

The create event does not support a branch filter. create 事件不支持分支过滤器。

The alternative would be using an if condition on your step or job:另一种方法是在您的步骤或工作上使用 if 条件:

if: ${{ contains(github.ref, 'refs/heads/releases/') }}

Here's more information: https://github.community/t/trigger-job-on-branch-created/16878/5这里有更多信息: https://github.community/t/trigger-job-on-branch-created/16878/5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM