|
|
|
@ -14,6 +14,7 @@ import (
|
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
|
|
|
"code.gitea.io/gitea/models/unit"
|
|
|
|
|
"code.gitea.io/gitea/modules/actions"
|
|
|
|
|
"code.gitea.io/gitea/modules/base"
|
|
|
|
|
context_module "code.gitea.io/gitea/modules/context"
|
|
|
|
|
"code.gitea.io/gitea/modules/log"
|
|
|
|
|
"code.gitea.io/gitea/modules/timeutil"
|
|
|
|
@ -57,6 +58,7 @@ type ViewResponse struct {
|
|
|
|
|
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
|
|
|
|
|
Done bool `json:"done"`
|
|
|
|
|
Jobs []*ViewJob `json:"jobs"`
|
|
|
|
|
Commit ViewCommit `json:"commit"`
|
|
|
|
|
} `json:"run"`
|
|
|
|
|
CurrentJob struct {
|
|
|
|
|
Title string `json:"title"`
|
|
|
|
@ -76,6 +78,25 @@ type ViewJob struct {
|
|
|
|
|
CanRerun bool `json:"canRerun"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ViewCommit struct {
|
|
|
|
|
LocaleCommit string `json:"localeCommit"`
|
|
|
|
|
LocalePushedBy string `json:"localePushedBy"`
|
|
|
|
|
ShortSha string `json:"shortSHA"`
|
|
|
|
|
Link string `json:"link"`
|
|
|
|
|
Pusher ViewUser `json:"pusher"`
|
|
|
|
|
Branch ViewBranch `json:"branch"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ViewUser struct {
|
|
|
|
|
DisplayName string `json:"displayName"`
|
|
|
|
|
Link string `json:"link"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ViewBranch struct {
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Link string `json:"link"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ViewJobStep struct {
|
|
|
|
|
Summary string `json:"summary"`
|
|
|
|
|
Duration string `json:"duration"`
|
|
|
|
@ -104,6 +125,10 @@ func ViewPost(ctx *context_module.Context) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
run := current.Run
|
|
|
|
|
if err := run.LoadAttributes(ctx); err != nil {
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, err.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resp := &ViewResponse{}
|
|
|
|
|
|
|
|
|
@ -123,6 +148,23 @@ func ViewPost(ctx *context_module.Context) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pusher := ViewUser{
|
|
|
|
|
DisplayName: run.TriggerUser.GetDisplayName(),
|
|
|
|
|
Link: run.TriggerUser.HomeLink(),
|
|
|
|
|
}
|
|
|
|
|
branch := ViewBranch{
|
|
|
|
|
Name: run.PrettyRef(),
|
|
|
|
|
Link: run.RefLink(),
|
|
|
|
|
}
|
|
|
|
|
resp.State.Run.Commit = ViewCommit{
|
|
|
|
|
LocaleCommit: ctx.Tr("actions.runs.commit"),
|
|
|
|
|
LocalePushedBy: ctx.Tr("actions.runs.pushed_by"),
|
|
|
|
|
ShortSha: base.ShortSha(run.CommitSHA),
|
|
|
|
|
Link: fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA),
|
|
|
|
|
Pusher: pusher,
|
|
|
|
|
Branch: branch,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var task *actions_model.ActionTask
|
|
|
|
|
if current.TaskID > 0 {
|
|
|
|
|
var err error
|
|
|
|
|