fix(actions): fix schedule cleanup and default branch switch (#39740)

Cancelling running schedule runs has not worked since
https://github.com/go-gitea/gitea/pull/35767: callers pass a branch name
like `main`, while schedule runs store the full ref like
`refs/heads/main`. Disabling Actions, archiving the repository or
changing the default branch left them running.

Fixing the ref alone would also cancel them on every push to the default
branch, which GitHub does not do, and whenever the Actions setting is
saved, so those paths now only replace the schedules.

Changing or renaming the default branch deleted the schedules without
registering the new branch's ones
(https://github.com/go-gitea/gitea/pull/28691), so they stopped until
the next push, and the API path kept the old ones. Both now switch the
schedules to the new default branch, since scheduled workflows only run
on the default branch.
This commit is contained in:
Zettat123 authored and GitHub committed 2026-10-14 19:34:46 +00:00
1 parent 41ccfce3e9
commit 919116568f
7 files changed
+135 -64

No files matched your search

+2 -1
View File
@@ -11,6 +11,7 @@ import (
"gitea.dev/models/db"
repo_model "gitea.dev/models/repo"
user_model "gitea.dev/models/user"
"gitea.dev/modules/git"
"gitea.dev/modules/timeutil"
"gitea.dev/modules/util"
webhook_module "gitea.dev/modules/webhook"
@@ -110,7 +111,7 @@ func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) ([
jobs, err := CancelPreviousJobs(
ctx,
repo.ID,
repo.DefaultBranch,
git.RefNameFromBranch(repo.DefaultBranch).String(),
"",
webhook_module.HookEventSchedule,
)