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

时间:2019-04-28 11:44:21

标签: github github-actions

我正试图找出一种方法,仅在将pr打开到主控器(即更改即将进入主控器)时运行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 个答案:

答案 0 :(得分:4)

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

on:
  pull_request:
    branches:
    - master

答案 1 :(得分:1)

使用ref代替action "Is Master Branch" { uses = "actions/bin/filter@master" args = "ref refs/heads/master" } 怎么样? (尽管我尚未测试此代码)

export class Ingredient {
   constructor(data?: any) {
     this.name = data.name;
     this.amount = data.amount;
     this.measurement = data.measurement;
   }
   public name: string = null;
   public amount: number = null;
   public measurement: string = null;
}