如何在Github操作中检查头分支是否与分支拉取请求上的特定模式匹配

如何在Github操作中检查头分支是否与分支拉取请求上的特定模式匹配,github,continuous-integration,pipeline,github-actions,Github,Continuous Integration,Pipeline,Github Actions,我希望在我的Github工作流操作中编写类似的内容: name: Deploy to branch with a specific pattern on: pull_request: branches: master && contains(github.ref, 'myPattern') # The current head branch contains a specific word 但是,它不起作用,我不想在运行作业后使用if来停止它,如下所示 name:

我希望在我的Github工作流操作中编写类似的内容:

name: Deploy to branch with a specific pattern

on:
  pull_request:
    branches: master && contains(github.ref, 'myPattern') # The current head branch contains a specific word
但是,它不起作用,我不想在运行作业后使用
if
来停止它,如下所示

name: Deploy to branch with a specific pattern

on:
  pull_request:
    branches: master

jobs:
  deployment:
    runs-on: ubuntu-latest
    if: contains(github.ref, 'myPattern')

那么,你知道如何实现它吗?

文档中已经非常清楚地说明了这一点

使用push和pull_请求事件时,可以将工作流配置为在特定分支或标记上运行。对于pull_请求事件,只计算基础上的分支和标记。如果只定义标记或分支,工作流将不会针对影响未定义Git ref的事件运行

分支、分支忽略、标记和标记忽略关键字接受全局模式,这些模式使用*和**通配符匹配多个分支或标记名称。有关详细信息,请参阅“”


海报上写着总支
on:
  push:
    # Sequence of patterns matched against refs/heads
    branches:    
      - master         # Push events on master branch
      - 'mona/octocat' # Push events to branches matching refs/heads/mona/octocat
      - 'releases/**'  # Push events to branches matching refs/heads/releases/10
    # Sequence of patterns matched against refs/tags
    tags:        
      - v1             # Push events to v1 tag
      - v1.*           # Push events to v1.0, v1.1, and v1.9 tags
Filter pattern cheat sheet
You can use special characters in path, branch, and tag filters.

*: Matches zero or more characters, but does not match the / character. For example, Octo* matches Octocat.
**: Matches zero or more of any character.
?: Matches zero or one single character. For example, Octoc?t matches Octocat.
+: Matches one or more of the proceeding character.
[] Matches one character listed in the brackets or included in ranges. Ranges can only include a-z, A-Z, and 0-9. For example, the range[0-9a-f] matches any digits or lowercase letter. For example, [CB]at matches Cat or Bat and [1-2]00 matches 100 and 200.
!: At the start of a pattern makes it negate previous positive patterns. It has no special meaning if not the first character.