diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-01-13 05:50:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-12 21:50:38 +0000 |
commit | 97292da96048b036cbe36b3ea66503ac568a73e7 (patch) | |
tree | 3104c11d619e6b11a82d6a898354dc4cf64ed0be /models/actions/run.go | |
parent | 6c6823935c4810a071a3919a88819b0ed156bf43 (diff) | |
download | gitea-97292da96048b036cbe36b3ea66503ac568a73e7.tar.gz gitea-97292da96048b036cbe36b3ea66503ac568a73e7.zip |
Fix schedule tasks bugs (#28691)
Fix #28157
This PR fix the possible bugs about actions schedule.
## The Changes
- Move `UpdateRepositoryUnit` and `SetRepoDefaultBranch` from models to
service layer
- Remove schedules plan from database and cancel waiting & running
schedules tasks in this repository when actions unit has been disabled
or global disabled.
- Remove schedules plan from database and cancel waiting & running
schedules tasks in this repository when default branch changed.
Diffstat (limited to 'models/actions/run.go')
-rw-r--r-- | models/actions/run.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/models/actions/run.go b/models/actions/run.go index 4656aa22a2..1a3701b0b0 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -168,13 +168,14 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err } // CancelRunningJobs cancels all running and waiting jobs associated with a specific workflow. -func CancelRunningJobs(ctx context.Context, repoID int64, ref, workflowID string) error { +func CancelRunningJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) error { // Find all runs in the specified repository, reference, and workflow with statuses 'Running' or 'Waiting'. runs, total, err := db.FindAndCount[ActionRun](ctx, FindRunOptions{ - RepoID: repoID, - Ref: ref, - WorkflowID: workflowID, - Status: []Status{StatusRunning, StatusWaiting}, + RepoID: repoID, + Ref: ref, + WorkflowID: workflowID, + TriggerEvent: event, + Status: []Status{StatusRunning, StatusWaiting}, }) if err != nil { return err |