Skip to content

Commit

Permalink
Only delete scheduled workflows when needed (go-gitea#29091)
Browse files Browse the repository at this point in the history
Fix go-gitea#29040

`handleSchedules` should be called only if `DetectWorkflows` should
detect schedule workflows
  • Loading branch information
Zettat123 committed Feb 18, 2024
1 parent 933cc4d commit bcb3e0c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions services/actions/notifier_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,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)
Expand Down Expand Up @@ -199,8 +200,10 @@ func notify(ctx context.Context, input *notifyInput) error {
}
}

if err := handleSchedules(ctx, schedules, commit, input, ref); err != nil {
return err
if shouldDetectSchedules {
if err := handleSchedules(ctx, schedules, commit, input, ref); err != nil {
return err
}
}

return handleWorkflows(ctx, detectedWorkflows, commit, input, ref)
Expand Down

0 comments on commit bcb3e0c

Please sign in to comment.