Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 09:54:24 +01:00

Only delete scheduled workflows when needed (#29091)

Fix #29040

`handleSchedules` should be called only if `DetectWorkflows` should
detect schedule workflows

(cherry picked from commit e600c35f066c79b717dc0c416b07d5c34502d286)
This commit is contained in:
Zettat123 2024-02-08 21:00:17 +08:00 committed by Earl Warren
parent cf78141bdd
commit 07eeab863b
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -170,10 +170,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)
@ -226,8 +227,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)