mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 22:13:26 +09:00
fix(actions): allow cancelling runs without running jobs (#35842)
My idea is to allow cancelling an stuck run with all jobs done, in case such a bug happens again to not require admin commands. Related #35832 Co-authored-by: Zettat123 <zettat123@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
co-authored by
Zettat123
silverwind
parent
6ff3a65708
commit
c210ef6dbb
@@ -19,7 +19,10 @@ func CancelRun(ctx context.Context, run *actions_model.ActionRun, jobs []*action
|
||||
if err != nil {
|
||||
return fmt.Errorf("CancelJobs: %w", err)
|
||||
}
|
||||
return nil
|
||||
if len(updatedJobs) > 0 {
|
||||
return nil // a job update already refreshed the run
|
||||
}
|
||||
return actions_model.SettleRunAfterCancel(ctx, run)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -27,14 +30,13 @@ func CancelRun(ctx context.Context, run *actions_model.ActionRun, jobs []*action
|
||||
CreateCommitStatusForRunJobs(ctx, run, jobs...)
|
||||
EmitJobsIfReadyByJobs(updatedJobs)
|
||||
NotifyWorkflowJobsStatusUpdate(ctx, updatedJobs...)
|
||||
if len(updatedJobs) == 0 {
|
||||
return run, nil
|
||||
}
|
||||
|
||||
reloaded, err := actions_model.GetRunByRepoAndID(ctx, run.RepoID, run.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GetRunByRepoAndID: %w", err)
|
||||
}
|
||||
NotifyWorkflowRunStatusUpdate(ctx, reloaded)
|
||||
if len(updatedJobs) > 0 || reloaded.Status != run.Status {
|
||||
NotifyWorkflowRunStatusUpdate(ctx, reloaded)
|
||||
}
|
||||
return reloaded, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user