From 324a8564570aff656c3980526fa471a3b3ff5051 Mon Sep 17 00:00:00 2001 From: Lucian Jones Date: Tue, 25 Jun 2019 10:13:06 +1200 Subject: [PATCH] add support for pull request action in when conditionals --- yaml/compiler/skip.go | 3 +++ yaml/compiler/skip_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/yaml/compiler/skip.go b/yaml/compiler/skip.go index a414f55..9a7ba92 100644 --- a/yaml/compiler/skip.go +++ b/yaml/compiler/skip.go @@ -26,6 +26,7 @@ type SkipData struct { Ref string Repo string Target string + Action string } // SkipFunc returns a function that can be used to skip @@ -47,6 +48,8 @@ func SkipFunc(data SkipData) func(*yaml.Container) bool { return true case !container.When.Target.Match(data.Target): return true + case !container.When.Action.Match(data.Action): + return true default: return false } diff --git a/yaml/compiler/skip_test.go b/yaml/compiler/skip_test.go index 4b98843..3769a6b 100644 --- a/yaml/compiler/skip_test.go +++ b/yaml/compiler/skip_test.go @@ -111,6 +111,19 @@ func TestSkipFunc(t *testing.T) { when: yaml.Conditions{Target: yaml.Condition{Exclude: []string{"prod"}}}, want: true, }, + // + // test action conditions + // + { + data: SkipData{Action: "opened"}, + when: yaml.Conditions{Action: yaml.Condition{Include: []string{"opened"}}}, + want: false, + }, + { + data: SkipData{Action: "opened"}, + when: yaml.Conditions{Action: yaml.Condition{Exclude: []string{"opened"}}}, + want: true, + }, } for i, test := range tests { container := &yaml.Container{When: test.when}