mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
Add API endpoints for getting action jobs status
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||
"code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
@@ -179,6 +180,24 @@ func ToTag(repo *repo_model.Repository, t *git.Tag) *api.Tag {
|
||||
}
|
||||
}
|
||||
|
||||
// ToActionTask convert a actions_model.ActionTask to an api.ActionTask
|
||||
func ToActionTask(ctx context.Context, repo *repo_model.Repository, t *actions_model.ActionTask) *api.ActionTask {
|
||||
if err := t.LoadAttributes(ctx); err != nil {
|
||||
log.Warn("LoadAttributes of ActionTask: %v", err)
|
||||
}
|
||||
return &api.ActionTask{
|
||||
ID: t.ID,
|
||||
JobName: t.Job.Name,
|
||||
WorkflowID: t.Job.Run.WorkflowID,
|
||||
Title: t.Job.Run.Title,
|
||||
Status: t.Status.String(),
|
||||
Commit: t.CommitSHA,
|
||||
Duration: t.Duration().String(),
|
||||
Started: t.Started.AsLocalTime(),
|
||||
Stopped: t.Stopped.AsLocalTime(),
|
||||
}
|
||||
}
|
||||
|
||||
// ToVerification convert a git.Commit.Signature to an api.PayloadCommitVerification
|
||||
func ToVerification(ctx context.Context, c *git.Commit) *api.PayloadCommitVerification {
|
||||
verif := asymkey_model.ParseCommitWithSignature(ctx, c)
|
||||
|
||||
Reference in New Issue
Block a user