feature!: Trigger changed Triggers, allowing multiple actions (#515)

* feature!: Trigger changed Triggers, allowing multiple actions

* bugfix: Warning message on trigger loops, prevented NPE

* cicd: Fix cyclo complexity with triggers
This commit is contained in:
James Read 2025-02-18 16:00:33 -08:00 committed by GitHub
parent 2cf538bab1
commit 2fc7c23416
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 5 deletions

View File

@ -21,7 +21,7 @@ type Action struct {
ExecOnFileCreatedInDir []string
ExecOnFileChangedInDir []string
ExecOnCalendarFile string
Trigger string
Triggers []string
MaxConcurrent int
MaxRate []RateSpec
Arguments []ActionArgument

View File

@ -580,9 +580,23 @@ func stepExecAfter(req *ExecutionRequest) bool {
}
func stepTrigger(req *ExecutionRequest) bool {
if req.Action.Trigger != "" {
if req.Action.Triggers == nil {
return true
}
if len(req.Tags) > 0 && req.Tags[0] == "trigger" {
log.Warnf("Trigger action is triggering another trigger action. This is allowed, but be careful not to create trigger loops.")
}
triggerLoop(req)
return true
}
func triggerLoop(req *ExecutionRequest) {
for _, triggerReq := range req.Action.Triggers {
trigger := &ExecutionRequest{
ActionTitle: req.Action.Trigger,
ActionTitle: triggerReq,
TrackingID: uuid.NewString(),
Tags: []string{"trigger"},
AuthenticatedUser: req.AuthenticatedUser,
@ -591,8 +605,6 @@ func stepTrigger(req *ExecutionRequest) bool {
req.executor.ExecRequest(trigger)
}
return true
}
func stepSaveLog(req *ExecutionRequest) bool {