mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-25 03:20:39 +00:00
Merge pull request #48 from lucianjon/drone-2685-include-action
add support for pull request action in when conditionals
This commit is contained in:
commit
04e984e628
@ -26,6 +26,7 @@ type SkipData struct {
|
|||||||
Ref string
|
Ref string
|
||||||
Repo string
|
Repo string
|
||||||
Target string
|
Target string
|
||||||
|
Action string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SkipFunc returns a function that can be used to skip
|
// SkipFunc returns a function that can be used to skip
|
||||||
@ -47,6 +48,8 @@ func SkipFunc(data SkipData) func(*yaml.Container) bool {
|
|||||||
return true
|
return true
|
||||||
case !container.When.Target.Match(data.Target):
|
case !container.When.Target.Match(data.Target):
|
||||||
return true
|
return true
|
||||||
|
case !container.When.Action.Match(data.Action):
|
||||||
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,19 @@ func TestSkipFunc(t *testing.T) {
|
|||||||
when: yaml.Conditions{Target: yaml.Condition{Exclude: []string{"prod"}}},
|
when: yaml.Conditions{Target: yaml.Condition{Exclude: []string{"prod"}}},
|
||||||
want: true,
|
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 {
|
for i, test := range tests {
|
||||||
container := &yaml.Container{When: test.when}
|
container := &yaml.Container{When: test.when}
|
||||||
|
Loading…
Reference in New Issue
Block a user