简体   繁体   English

仅在pr目标为master时运行GitHub操作

[英]Only run GitHub actions if pr target is master

I am trying to figure out a way how to run GitHub workflow only when pr is opened into master ie changes are going into master. 我试图找出一种方法,仅当pr打开master时才运行GitHub工作流,即更改即将进入master。

So far I got to this point 到目前为止,我到了这一点

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"
}

When I open pull request merging development branch into master branch my Install action is not ran, because Is Master Branch returns 当我打开将development分支合并到master分支的拉请求时,我的Install操作未运行,因为Is Master Branch返回了

refs/heads/development does not match refs/heads/master 裁判/负责人/发展与裁判/负责人/大师不匹配

With the new YAML syntax, you can achieve this like so: 使用新的YAML语法,您可以这样实现:

on:
  pull_request:
    branches:
    - master

How about using ref instead of branch ? ref代替branch怎么样? (I haven't tested this code though) (尽管我尚未测试此代码)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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