Skip to content

Commit 0dc1361

Browse files
committed
detect schedule workflows in when repo setting changes
1 parent d18592e commit 0dc1361

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

services/repository/setting.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
"code.gitea.io/gitea/models/db"
1313
repo_model "code.gitea.io/gitea/models/repo"
1414
"code.gitea.io/gitea/models/unit"
15-
webhook_module "code.gitea.io/gitea/modules/webhook"
15+
"code.gitea.io/gitea/modules/log"
16+
actions_service "code.gitea.io/gitea/services/actions"
1617
)
1718

1819
// UpdateRepositoryUnits updates a repository's units
@@ -29,14 +30,17 @@ func UpdateRepositoryUnits(ctx context.Context, repo *repo_model.Repository, uni
2930
}
3031

3132
if slices.Contains(deleteUnitTypes, unit.TypeActions) {
32-
if err := actions_model.CancelRunningJobs(
33-
ctx,
34-
repo.ID,
35-
repo.DefaultBranch,
36-
"",
37-
webhook_module.HookEventSchedule,
38-
); err != nil {
39-
return fmt.Errorf("CancelRunningJobs: %w", err)
33+
if err := actions_model.CleanRepoScheduleTasks(ctx, repo); err != nil {
34+
log.Error("CleanRepoScheduleTasks: %v", err)
35+
}
36+
}
37+
38+
for _, u := range units {
39+
if u.Type == unit.TypeActions {
40+
if err := actions_service.DetectAndHandleSchedules(ctx, repo); err != nil {
41+
return fmt.Errorf("detect and handle schedule workflows: %w", err)
42+
}
43+
break
4044
}
4145
}
4246

0 commit comments

Comments
 (0)