Skip to content

Commit 55562f9

Browse files
Zettat123delvh
andauthored
Update scheduled tasks even if changes are pushed by "ActionsUser" (#32246) (#32252)
Backport #32246 Fix #32219 Co-authored-by: delvh <dev.lh@web.de>
1 parent 24b65f1 commit 55562f9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

services/actions/notifier_helper.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,20 @@ func (input *notifyInput) Notify(ctx context.Context) {
115115
}
116116

117117
func notify(ctx context.Context, input *notifyInput) error {
118+
shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch
118119
if input.Doer.IsActions() {
119120
// avoiding triggering cyclically, for example:
120121
// a comment of an issue will trigger the runner to add a new comment as reply,
121122
// and the new comment will trigger the runner again.
122123
log.Debug("ignore executing %v for event %v whose doer is %v", getMethod(ctx), input.Event, input.Doer.Name)
124+
125+
// we should update schedule tasks in this case, because
126+
// 1. schedule tasks cannot be triggered by other events, so cyclic triggering will not occur
127+
// 2. some schedule tasks may update the repo periodically, so the refs of schedule tasks need to be updated
128+
if shouldDetectSchedules {
129+
return DetectAndHandleSchedules(ctx, input.Repo)
130+
}
131+
123132
return nil
124133
}
125134
if input.Repo.IsEmpty || input.Repo.IsArchived {
@@ -173,7 +182,6 @@ func notify(ctx context.Context, input *notifyInput) error {
173182

174183
var detectedWorkflows []*actions_module.DetectedWorkflow
175184
actionsConfig := input.Repo.MustGetUnit(ctx, unit_model.TypeActions).ActionsConfig()
176-
shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch
177185
workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit,
178186
input.Event,
179187
input.Payload,

0 commit comments

Comments
 (0)