Github 操作:有没有办法对从特定分支打开的拉取请求执行 运行 操作?

Github Actions: Is there a way to run actions on Pull Requests opened from specific branches?

我正在尝试创建一个操作,当来自特定分支的拉取请求针对 master 打开时,其工作流程 运行s。我目前拥有的 运行 所有分支机构针对 master 打开的所有 Pull 请求的工作流程。

name: Auto Approve Pull Request
on:
  pull_request:
    branches:
      - 'master'
      - 'skip-*'

jobs:
  build:
    name: Approve PR
    runs-on: ubuntu-latest
    steps:
      - name: Fetch out code
        uses: username/my-github-repo@master
        with:
          token: ******
        env:
          BRANCH_PREFIX: "skip-*"
          PULL_REQUEST_BRANCH: "master"

我想在名为 skip-*.

的分支上实现 运行 的工作流

我找到的解决方案是使用 if 语句来检查 head-ref 分支名称是否匹配(开头为)skip-

这是我的解决方案:

name: Auto Approve Pull Request
on:
  pull_request:
    branches:
      - 'master'

jobs:
  build:
    name: Approve PR
    runs-on: ubuntu-latest
    if: startsWith(github.head_ref, 'skip-') == true
    steps:
      - name: Fetch out code
        uses: username/my-github-repo@master
        with:
          token: ******
        env:
          BRANCH_PREFIX: "skip-*"
          PULL_REQUEST_BRANCH: "master"

备注: