Skip to content

Commit 81aec6d

Browse files
Zettat123delvh
andauthored
Update scheduled tasks even if changes are pushed by "ActionsUser" (#32246)
Fix #32219 --------- Co-authored-by: delvh <[email protected]>
1 parent 74664b0 commit 81aec6d

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
@@ -116,11 +116,20 @@ func (input *notifyInput) Notify(ctx context.Context) {
116116
}
117117

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

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

0 commit comments

Comments
 (0)