仅当Pull Request的目标分支为"master"时,才运行GitHub Actions。

4
我正在尝试找到一种方法,只有在PR被打开且更改提交至主干(master)时才运行GitHub工作流程。
到目前为止,我已经做到了这一步。
workflow "Install Yarn Dependencies" {
  on = "pull_request"
  resolves = ["Install"]
}

action "Is Master Branch" {
  uses = "actions/bin/filter@master"
  args = "branch master"
}

action "Install" {
  needs = "Is Master Branch"
  uses = "nuxt/actions-yarn@master"
  args = "install"
}

当我打开拉取请求,将 development 分支合并到 master 分支时,我的 Install 操作未运行,因为 Is Master Branch 返回:

refs/heads/development 与 refs/heads/master 不匹配

2个回答

4

使用新的YAML语法,您可以像这样实现:

on:
  pull_request:
    branches:
    - master

2
如何使用ref替代branch?(虽然我还没有测试过这段代码) 最初的回答。
action "Is Master Branch" {
  uses = "actions/bin/filter@master"
  args = "ref refs/heads/master"
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接