mirror of
https://github.com/go-gitea/gitea
synced 2025-07-03 09:07:19 +00:00
Show latest run when visit /run/latest (#31808)
Proposal from https://github.com/go-gitea/gitea/issues/27911#issuecomment-2271982172 When visit latest run path, such as `/{user}/{repo}/actions/runs/latest`. It renders latest run instead of index=0 currently.
This commit is contained in:
@ -361,6 +361,19 @@ func GetRunByIndex(ctx context.Context, repoID, index int64) (*ActionRun, error)
|
||||
return run, nil
|
||||
}
|
||||
|
||||
func GetLatestRun(ctx context.Context, repoID int64) (*ActionRun, error) {
|
||||
run := &ActionRun{
|
||||
RepoID: repoID,
|
||||
}
|
||||
has, err := db.GetEngine(ctx).Where("repo_id=?", repoID).Desc("index").Get(run)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, fmt.Errorf("latest run with repo_id %d: %w", repoID, util.ErrNotExist)
|
||||
}
|
||||
return run, nil
|
||||
}
|
||||
|
||||
func GetWorkflowLatestRun(ctx context.Context, repoID int64, workflowFile, branch, event string) (*ActionRun, error) {
|
||||
var run ActionRun
|
||||
q := db.GetEngine(ctx).Where("repo_id=?", repoID).
|
||||
|
Reference in New Issue
Block a user