Skip to content

Commit e600c35

Browse files
authored
Only delete scheduled workflows when needed (go-gitea#29091)
Fix go-gitea#29040 `handleSchedules` should be called only if `DetectWorkflows` should detect schedule workflows
1 parent 8c6ffda commit e600c35

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

services/actions/notifier_helper.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,11 @@ func notify(ctx context.Context, input *notifyInput) error {
157157

158158
var detectedWorkflows []*actions_module.DetectedWorkflow
159159
actionsConfig := input.Repo.MustGetUnit(ctx, unit_model.TypeActions).ActionsConfig()
160+
shouldDetectSchedules := input.Event == webhook_module.HookEventPush && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch
160161
workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit,
161162
input.Event,
162163
input.Payload,
163-
input.Event == webhook_module.HookEventPush && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch,
164+
shouldDetectSchedules,
164165
)
165166
if err != nil {
166167
return fmt.Errorf("DetectWorkflows: %w", err)
@@ -207,8 +208,10 @@ func notify(ctx context.Context, input *notifyInput) error {
207208
}
208209
}
209210

210-
if err := handleSchedules(ctx, schedules, commit, input, ref); err != nil {
211-
return err
211+
if shouldDetectSchedules {
212+
if err := handleSchedules(ctx, schedules, commit, input, ref); err != nil {
213+
return err
214+
}
212215
}
213216

214217
return handleWorkflows(ctx, detectedWorkflows, commit, input, ref)

0 commit comments

Comments
 (0)