Only delete scheduled workflows when needed (#29091)

Fix #29040

`handleSchedules` should be called only if `DetectWorkflows` should
detect schedule workflows
pull/29090/head^2
Zettat123 10 months ago committed by GitHub
parent 8c6ffdac37
commit e600c35f06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      services/actions/notifier_helper.go

@ -157,10 +157,11 @@ 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 && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch
workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit,
input.Event,
input.Payload,
input.Event == webhook_module.HookEventPush && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch,
shouldDetectSchedules,
)
if err != nil {
return fmt.Errorf("DetectWorkflows: %w", err)
@ -207,9 +208,11 @@ func notify(ctx context.Context, input *notifyInput) error {
}
}
if shouldDetectSchedules {
if err := handleSchedules(ctx, schedules, commit, input, ref); err != nil {
return err
}
}
return handleWorkflows(ctx, detectedWorkflows, commit, input, ref)
}

Loading…
Cancel
Save