如果 pr 目标是 master,只有 运行 GitHub 个动作

Only run GitHub actions if pr target is master

我正在尝试找出一种方法如何 运行 GitHub 仅当 pr 打开到 master 时工作流程,即更改将进入 master。

到此为止

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 b运行ch 到 master b运行ch 时,我的 Install 操作不是 运行 , 因为 Is Master Branch returns

refs/heads/development does not match refs/heads/master

ref 代替 branch 怎么样? (不过我还没有测试过这段代码)

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

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

on:
  pull_request:
    branches:
    - master