@@ -178,7 +178,7 @@ func notify(ctx context.Context, input *notifyInput) error {
178178 return fmt .Errorf ("gitRepo.GetCommit: %w" , err )
179179 }
180180
181- if skipWorkflows (input , commit ) {
181+ if skipWorkflows (ctx , input , commit ) {
182182 return nil
183183 }
184184
@@ -243,7 +243,7 @@ func notify(ctx context.Context, input *notifyInput) error {
243243 return handleWorkflows (ctx , detectedWorkflows , commit , input , ref .String ())
244244}
245245
246- func skipWorkflows (input * notifyInput , commit * git.Commit ) bool {
246+ func skipWorkflows (ctx context. Context , input * notifyInput , commit * git.Commit ) bool {
247247 // skip workflow runs with a configured skip-ci string in commit message or pr title if the event is push or pull_request(_sync)
248248 // https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
249249 skipWorkflowEvents := []webhook_module.HookEventType {
@@ -265,12 +265,21 @@ func skipWorkflows(input *notifyInput, commit *git.Commit) bool {
265265 }
266266 if input .Event == webhook_module .HookEventWorkflowRun {
267267 wrun , ok := input .Payload .(* api.WorkflowRunPayload )
268- if ok && wrun .WorkflowRun != nil && wrun .WorkflowRun .Event == "workflow_run" {
269- // skip workflow runs triggered by another workflow run
270- // TODO GitHub allows chaining up to 5 of them
271- log .Debug ("repo %s: skipped workflow_run because of recursive event" , input .Repo .RepoPath ())
272- return true
268+ for i := 0 ; i < 5 && ok && wrun .WorkflowRun != nil ; i ++ {
269+ if wrun .WorkflowRun .Event != "workflow_run" {
270+ return false
271+ }
272+ r , _ := actions_model .GetRunByID (ctx , wrun .WorkflowRun .ID )
273+ var err error
274+ wrun , err = r .GetWorkflowRunEventPayload ()
275+ if err != nil {
276+ log .Error ("GetWorkflowRunEventPayload: %v" , err )
277+ return true
278+ }
273279 }
280+ // skip workflow runs events exceeding the maxiumum of 5 recursive events
281+ log .Debug ("repo %s: skipped workflow_run because of recursive event of 5" , input .Repo .RepoPath ())
282+ return true
274283 }
275284 return false
276285}
0 commit comments