From f1597338d6a18c6ccc218daa2e7a906b51168ba6 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Sat, 12 Oct 2024 13:41:55 +0800 Subject: [PATCH 1/2] fix updating schedule tasks --- services/actions/notifier_helper.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index b21d889d0369e..d2d6f0d76853e 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -116,11 +116,20 @@ func (input *notifyInput) Notify(ctx context.Context) { } func notify(ctx context.Context, input *notifyInput) error { + shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch if input.Doer.IsActions() { // avoiding triggering cyclically, for example: // a comment of an issue will trigger the runner to add a new comment as reply, // and the new comment will trigger the runner again. log.Debug("ignore executing %v for event %v whose doer is %v", getMethod(ctx), input.Event, input.Doer.Name) + + // we should update schedule tasks in this case, because + // 1. schedule tasks cannot be triggerd by other events, so cyclic triggering will not occur + // 2. some schedule tasks may update the repo periodically, so the refs of schedule tasks need to be updated + if shouldDetectSchedules { + return DetectAndHandleSchedules(ctx, input.Repo) + } + return nil } if input.Repo.IsEmpty || input.Repo.IsArchived { @@ -174,7 +183,6 @@ func notify(ctx context.Context, input *notifyInput) error { var detectedWorkflows []*actions_module.DetectedWorkflow actionsConfig := input.Repo.MustGetUnit(ctx, unit_model.TypeActions).ActionsConfig() - shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit, input.Event, input.Payload, From 088a01fe87af537681060266054a05b423e1fd6d Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Sat, 12 Oct 2024 16:10:04 +0800 Subject: [PATCH 2/2] Update services/actions/notifier_helper.go Co-authored-by: delvh --- 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 d2d6f0d76853e..323c6a76e422c 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -124,7 +124,7 @@ func notify(ctx context.Context, input *notifyInput) error { log.Debug("ignore executing %v for event %v whose doer is %v", getMethod(ctx), input.Event, input.Doer.Name) // we should update schedule tasks in this case, because - // 1. schedule tasks cannot be triggerd by other events, so cyclic triggering will not occur + // 1. schedule tasks cannot be triggered by other events, so cyclic triggering will not occur // 2. some schedule tasks may update the repo periodically, so the refs of schedule tasks need to be updated if shouldDetectSchedules { return DetectAndHandleSchedules(ctx, input.Repo)