简体   繁体   中英

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. 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 .

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.

The create event does not support a branch filter.

The alternative would be using an if condition on your step or job:

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

Here's more information: https://github.community/t/trigger-job-on-branch-created/16878/5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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