From 10833a42b24a8da7c3a08d819d7938c3b0dc90c9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 21 Jan 2024 11:26:53 +0800 Subject: [PATCH 1/2] Fix schedule not trigger bug because matching full ref name with short ref name --- services/actions/notifier_helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 0618f15602ee5..ac25c7f3f7d6a 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -159,7 +159,7 @@ func notify(ctx context.Context, input *notifyInput) error { workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit, input.Event, input.Payload, - input.Event == webhook_module.HookEventPush && input.Ref == input.Repo.DefaultBranch, + input.Event == webhook_module.HookEventPush && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch, ) if err != nil { return fmt.Errorf("DetectWorkflows: %w", err) From 81b8bb54c6f2a000bbbb311d9f80a950dbbf8110 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 21 Jan 2024 11:40:07 +0800 Subject: [PATCH 2/2] Improve the trace log of trigger actions --- services/actions/notifier_helper.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index ac25c7f3f7d6a..2a3ffb76f30d2 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -165,18 +165,22 @@ func notify(ctx context.Context, input *notifyInput) error { return fmt.Errorf("DetectWorkflows: %w", err) } - if len(workflows) == 0 { - log.Trace("repo %s with commit %s couldn't find workflows", input.Repo.RepoPath(), commit.ID) - } else { - for _, wf := range workflows { - if actionsConfig.IsWorkflowDisabled(wf.EntryName) { - log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName) - continue - } + log.Trace("repo %s with commit %s event %s find %d workflows and %d schedules", + input.Repo.RepoPath(), + commit.ID, + input.Event, + len(workflows), + len(schedules), + ) - if wf.TriggerEvent.Name != actions_module.GithubEventPullRequestTarget { - detectedWorkflows = append(detectedWorkflows, wf) - } + for _, wf := range workflows { + if actionsConfig.IsWorkflowDisabled(wf.EntryName) { + log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName) + continue + } + + if wf.TriggerEvent.Name != actions_module.GithubEventPullRequestTarget { + detectedWorkflows = append(detectedWorkflows, wf) } }