diff --git a/models/actions/run.go b/models/actions/run.go index bb63509bd8d..f945b97209f 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -373,14 +373,15 @@ func ShouldBlockRunByConcurrency(ctx context.Context, actionRun *ActionRun) (boo return false, nil } - concurrentRunsNum, err := db.Count[ActionRun](ctx, &FindRunOptions{ + concurrentRuns, err := db.Find[ActionRun](ctx, &FindRunOptions{ RepoID: actionRun.RepoID, ConcurrencyGroup: actionRun.ConcurrencyGroup, Status: []Status{StatusWaiting, StatusRunning}, }) if err != nil { - return false, fmt.Errorf("count running and waiting runs: %w", err) + return false, fmt.Errorf("find running and waiting runs: %w", err) } + previousRuns := slices.DeleteFunc(concurrentRuns, func(r *ActionRun) bool { return r.ID == actionRun.ID }) - return concurrentRunsNum > 0, nil + return len(previousRuns) > 0, nil }