From e1a16634b6e6306f43ae9f07da8d7f8e55ff8a2e Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 29 Jul 2019 20:37:04 -0700 Subject: [PATCH] added action to conditionals --- CHANGELOG.md | 1 + operator/runner/runner.go | 1 + trigger/skip.go | 4 ++++ trigger/trigger.go | 3 +++ 4 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a31970236..d7966c016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - disable github status for cron jobs +- support for action in conditionals, by [@bradrydzewski](https://github.com/bradrydzewski). [#2685](https://github.com/drone/drone/issues/2685). ### Fixed diff --git a/operator/runner/runner.go b/operator/runner/runner.go index eb85e99b9..a247e8194 100644 --- a/operator/runner/runner.go +++ b/operator/runner/runner.go @@ -260,6 +260,7 @@ func (r *Runner) Run(ctx context.Context, id int64) error { ) comp.SkipFunc = compiler.SkipFunc( compiler.SkipData{ + Action: m.Build.Action, Branch: m.Build.Target, Cron: m.Build.Cron, Event: m.Build.Event, diff --git a/trigger/skip.go b/trigger/skip.go index f211acb0f..eedd8e246 100644 --- a/trigger/skip.go +++ b/trigger/skip.go @@ -33,6 +33,10 @@ func skipEvent(document *yaml.Pipeline, event string) bool { return !document.Trigger.Event.Match(event) } +func skipAction(document *yaml.Pipeline, action string) bool { + return !document.Trigger.Action.Match(action) +} + func skipInstance(document *yaml.Pipeline, instance string) bool { return !document.Trigger.Instance.Match(instance) } diff --git a/trigger/trigger.go b/trigger/trigger.go index 4fe88f060..1fe55c7e4 100644 --- a/trigger/trigger.go +++ b/trigger/trigger.go @@ -259,6 +259,9 @@ func (t *triggerer) Trigger(ctx context.Context, repo *core.Repository, base *co } else if skipEvent(pipeline, base.Event) { logger = logger.WithField("pipeline", pipeline.Name) logger.Infoln("trigger: skipping pipeline, does not match event") + } else if skipAction(pipeline, base.Action) { + logger = logger.WithField("pipeline", pipeline.Name) + logger.Infoln("trigger: skipping pipeline, does not match action") } else if skipRef(pipeline, base.Ref) { logger = logger.WithField("pipeline", pipeline.Name) logger.Infoln("trigger: skipping pipeline, does not match ref")