added action to when clause

This commit is contained in:
Brad Rydzewski 2019-06-13 18:11:18 -07:00
parent a338c245d7
commit 4889634ea9
3 changed files with 8 additions and 1 deletions

View File

@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Added Action field to trigger and when clause, by [@bradrydzewski](https://github.com/bradrydzewski).
### Fixed

View File

@ -18,6 +18,7 @@ import filepath "github.com/bmatcuk/doublestar"
// Conditions defines a group of conditions.
type Conditions struct {
Action Condition `json:"action,omitempty"`
Cron Condition `json:"cron,omitempty"`
Ref Condition `json:"ref,omitempty"`
Repo Condition `json:"repo,omitempty"`

View File

@ -122,6 +122,9 @@ func printConcurrency(w writer, v yaml.Concurrency) {
func printConditions(w writer, name string, v yaml.Conditions) {
w.WriteTag(name)
w.IndentIncrease()
if !isConditionEmpty(v.Action) {
printCondition(w, "action", v.Action)
}
if !isConditionEmpty(v.Branch) {
printCondition(w, "branch", v.Branch)
}
@ -276,7 +279,9 @@ func isConcurrencyEmpty(v yaml.Concurrency) bool {
// helper function returns true if the conditions
// object is empty.
func isConditionsEmpty(v yaml.Conditions) bool {
return isConditionEmpty(v.Branch) &&
return isConditionEmpty(v.Action) &&
isConditionEmpty(v.Branch) &&
isConditionEmpty(v.Cron) &&
isConditionEmpty(v.Event) &&
isConditionEmpty(v.Instance) &&
isConditionEmpty(v.Paths) &&