1
1
Fork 1
mirror of https://github.com/go-gitea/gitea.git synced 2024-05-09 03:46:06 +02:00

Compare commits

...

43 Commits

Author SHA1 Message Date
Chester 422c6222bc
Merge fc3dc33906 into 27861d711b 2024-04-27 00:16:31 -04:00
GiteaBot 27861d711b [skip ci] Updated translations via Crowdin 2024-04-27 00:24:31 +00:00
chesterip fc3dc33906 Fix template 2024-04-26 09:56:31 -04:00
chesterip 04abcc7cbd Fix letter case 2024-04-26 09:41:41 -04:00
chesterip e7bcc1bb0c Merge branch 'main' of github.com:go-gitea/gitea into api-repo-actions 2024-04-26 09:40:42 -04:00
chesterip 86493c27cf Fix as suggested 2024-04-26 09:40:38 -04:00
Chester f954f208ba
Update modules/structs/repo_actions.go
Co-authored-by: yp05327 <576951401@qq.com>
2024-04-26 09:38:34 -04:00
chesterip 2d53041157 Return err in ToActionTask 2024-04-23 22:19:19 -04:00
chesterip 5f26e8a634 Fix format 2024-04-23 20:08:07 -04:00
chesterip e0e094161f Fix URL 2024-04-23 19:09:43 -04:00
Chester 8d450136f4
Merge branch 'main' into api-repo-actions 2024-04-24 07:08:21 +08:00
chesterip 87ef8b75b1 Fix list options 2024-04-23 19:08:09 -04:00
Chester 0e61648d23
Merge branch 'main' into api-repo-actions 2024-04-19 22:20:41 +08:00
chesterip 0aabe97853 Merge branch 'main' of github.com:go-gitea/gitea into api-repo-actions 2024-04-18 22:20:40 -04:00
chesterip 34777376d6 Use GetListOptions() and panic() 2024-04-18 22:19:35 -04:00
chesterip ae25e049e4 :Merge branch 'main' of github.com:go-gitea/gitea into api-repo-actions 2024-04-03 21:34:21 -04:00
chesterip ad16583181 Add error res to swagger 2024-04-03 21:34:15 -04:00
chesterip 4310284a80 Reducing queries 2024-04-03 11:50:24 -04:00
chesterip 1028eefe48 move to db.find 2024-04-03 11:37:06 -04:00
chesterip 2c8249ba1e More fixes after mreging from main 2024-04-03 11:26:01 -04:00
chesterip e05fc9ab45 Fix broken json after resolving merge conflict 2024-04-03 11:15:04 -04:00
Chester a0be04f94f
Merge branch 'main' into api-repo-actions 2024-04-03 11:11:41 -04:00
Chester e61a33eba3
Merge branch 'main' into api-repo-actions 2023-10-20 14:56:35 -04:00
Chester 5ababc57bf
Merge branch 'main' into api-repo-actions 2023-09-11 14:24:40 -04:00
Chester 878eeedde8
Update modules/structs/repo_actions.go
Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
2023-09-11 14:24:32 -04:00
Chester b94cbda0bc
Update modules/structs/repo_actions.go
Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
2023-09-11 14:24:25 -04:00
Chester a348da4cfd
Update modules/structs/repo_actions.go
Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
2023-09-11 14:24:18 -04:00
Chester 083d718723
Merge branch 'main' into api-repo-actions 2023-09-05 19:22:28 -04:00
Chester 7617e9e0cd
Merge branch 'main' into api-repo-actions 2023-08-30 11:52:22 -04:00
chesterip 6928b37ab3 Update template using generate swagger 2023-08-30 11:50:25 -04:00
chesterip a9cdb7ea9b Fix template 2023-08-30 11:40:03 -04:00
chesterip 4d9a231912 Fix template 2023-08-30 11:38:46 -04:00
chesterip 1ba5701536 Fix var-naming 2023-08-30 11:34:01 -04:00
chesterip 80a2c8ee38 Merge remote-tracking branch 'origin/main' into api-repo-actions 2023-08-30 11:31:23 -04:00
chesterip 5625bc505b Update Swagger template 2023-08-23 10:22:33 -04:00
chesterip 38d1197a39 Merge branch 'main' of github.com:go-gitea/gitea into api-repo-actions 2023-08-23 10:14:18 -04:00
chesterip fdfc2f490f Merge branch 'api-repo-actions' of github.com:chesteripz/gitea into api-repo-actions 2023-08-23 10:13:45 -04:00
chesterip 5ebefc85ca align with GitHub Actions 2023-08-23 10:13:39 -04:00
Chester 246873acc0
Update routers/api/v1/api.go
Co-authored-by: yp05327 <576951401@qq.com>
2023-08-23 09:42:07 -04:00
chesterip 8f787dfe66 Update copyright message 2023-08-22 20:11:40 -04:00
chesterip 6870e1a60c Use the run index instead, since it's the number used in FE 2023-08-22 20:07:37 -04:00
chesterip 8b5443acdb Fix template 2023-08-22 20:00:59 -04:00
chesterip b8a61a6ba4 Add API endpoints for getting action jobs status 2023-08-22 19:58:55 -04:00
7 changed files with 301 additions and 0 deletions

View File

@ -0,0 +1,34 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
import (
"time"
)
// ActionTask represents a ActionTask
type ActionTask struct {
ID int64 `json:"id"`
Name string `json:"name"`
HeadBranch string `json:"head_branch"`
HeadSHA string `json:"head_sha"`
RunNumber int64 `json:"run_number"`
Event string `json:"event"`
DisplayTitle string `json:"display_title"`
Status string `json:"status"`
WorkflowID string `json:"workflow_id"`
URL string `json:"url"`
// swagger:strfmt date-time
CreatedAt time.Time `json:"created_at"`
// swagger:strfmt date-time
UpdatedAt time.Time `json:"updated_at"`
// swagger:strfmt date-time
RunStartedAt time.Time `json:"run_started_at"`
}
// ActionTaskResponse returns a ActionTask
type ActionTaskResponse struct {
Entries []*ActionTask `json:"workflow_runs"`
TotalCount int64 `json:"total_count"`
}

View File

@ -436,6 +436,7 @@ oauth_signin_submit=Vincular conta
oauth.signin.error=Ocorreu um erro durante o processamento do pedido de autorização. Se este erro persistir, contacte o administrador.
oauth.signin.error.access_denied=O pedido de autorização foi negado.
oauth.signin.error.temporarily_unavailable=A autorização falhou porque o servidor de autenticação está temporariamente indisponível. Tente mais tarde.
oauth_callback_unable_auto_reg=O registo automático está habilitado, mas o fornecedor OAuth2 %[1]s sinalizou campos em falta: %[2]s, por isso não foi possível criar uma conta automaticamente. Crie ou vincule uma conta ou contacte o administrador do sítio.
openid_connect_submit=Estabelecer ligação
openid_connect_title=Estabelecer ligação a uma conta existente
openid_connect_desc=O URI do OpenID escolhido Ă© desconhecido. Associe-o a uma nova conta aqui.

View File

@ -1168,6 +1168,9 @@ func Routes() *web.Route {
m.Post("", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, bind(api.CreateTagOption{}), repo.CreateTag)
m.Delete("/*", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.DeleteTag)
}, reqRepoReader(unit.TypeCode), context.ReferencesGitRepo(true))
m.Group("/actions", func() {
m.Get("/tasks", repo.ListActionTasks)
}, reqRepoReader(unit.TypeActions), context.ReferencesGitRepo(true))
m.Group("/keys", func() {
m.Combo("").Get(repo.ListDeployKeys).
Post(bind(api.CreateKeyOption{}), repo.CreateDeployKey)

View File

@ -0,0 +1,80 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package repo
import (
"net/http"
actions_model "code.gitea.io/gitea/models/actions"
"code.gitea.io/gitea/models/db"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/routers/api/v1/utils"
"code.gitea.io/gitea/services/context"
"code.gitea.io/gitea/services/convert"
)
// ListActionTasks list all the actions of a repository
func ListActionTasks(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/actions/tasks repository ListActionTasks
// ---
// summary: List a repository's action tasks
// produces:
// - application/json
// parameters:
// - name: owner
// in: path
// description: owner of the repo
// type: string
// required: true
// - name: repo
// in: path
// description: name of the repo
// type: string
// required: true
// - name: page
// in: query
// description: page number of results to return (1-based)
// type: integer
// - name: limit
// in: query
// description: page size of results, default maximum page size is 50
// type: integer
// responses:
// "200":
// "$ref": "#/responses/TasksList"
// "400":
// "$ref": "#/responses/error"
// "403":
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"
// "409":
// "$ref": "#/responses/conflict"
// "422":
// "$ref": "#/responses/validationError"
tasks, total, err := db.FindAndCount[actions_model.ActionTask](ctx, &actions_model.FindTaskOptions{
ListOptions: utils.GetListOptions(ctx),
RepoID: ctx.Repo.Repository.ID,
})
if err != nil {
ctx.Error(http.StatusInternalServerError, "ListActionTasks", err)
return
}
res := new(api.ActionTaskResponse)
res.TotalCount = total
res.Entries = make([]*api.ActionTask, len(tasks))
for i := range tasks {
convertedTask, err := convert.ToActionTask(ctx, tasks[i])
if err != nil {
ctx.Error(http.StatusInternalServerError, "ToActionTask", err)
return
}
res.Entries[i] = convertedTask
}
ctx.JSON(http.StatusOK, &res)
}

View File

@ -415,6 +415,13 @@ type swaggerRepoNewIssuePinsAllowed struct {
Body api.NewIssuePinsAllowed `json:"body"`
}
// TasksList
// swagger:response TasksList
type swaggerRepoTasksList struct {
// in:body
Body api.ActionTaskResponse `json:"body"`
}
// swagger:response Compare
type swaggerCompare struct {
// in:body

View File

@ -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"
git_model "code.gitea.io/gitea/models/git"
@ -24,6 +25,7 @@ import (
"code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/gitdiff"
@ -193,6 +195,31 @@ 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, t *actions_model.ActionTask) (*api.ActionTask, error) {
if err := t.LoadAttributes(ctx); err != nil {
return nil, err
}
url := strings.TrimSuffix(setting.AppURL, "/") + t.GetRunLink()
return &api.ActionTask{
ID: t.ID,
Name: t.Job.Name,
HeadBranch: t.Job.Run.PrettyRef(),
HeadSHA: t.Job.CommitSHA,
RunNumber: t.Job.Run.Index,
Event: t.Job.Run.TriggerEvent,
DisplayTitle: t.Job.Run.Title,
Status: t.Status.String(),
WorkflowID: t.Job.Run.WorkflowID,
URL: url,
CreatedAt: t.Created.AsLocalTime(),
UpdatedAt: t.Updated.AsLocalTime(),
RunStartedAt: t.Started.AsLocalTime(),
}, nil
}
// 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)

View File

@ -3997,6 +3997,66 @@
}
}
},
"/repos/{owner}/{repo}/actions/tasks": {
"get": {
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "List a repository's action tasks",
"operationId": "ListActionTasks",
"parameters": [
{
"type": "string",
"description": "owner of the repo",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repo",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "page number of results to return (1-based)",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "page size of results, default maximum page size is 50",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"$ref": "#/responses/TasksList"
},
"400": {
"$ref": "#/responses/error"
},
"403": {
"$ref": "#/responses/forbidden"
},
"404": {
"$ref": "#/responses/notFound"
},
"409": {
"$ref": "#/responses/conflict"
},
"422": {
"$ref": "#/responses/validationError"
}
}
}
},
"/repos/{owner}/{repo}/actions/variables": {
"get": {
"produces": [
@ -17953,6 +18013,89 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"ActionTask": {
"description": "ActionTask represents a ActionTask",
"type": "object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time",
"x-go-name": "CreatedAt"
},
"display_title": {
"type": "string",
"x-go-name": "DisplayTitle"
},
"event": {
"type": "string",
"x-go-name": "Event"
},
"head_branch": {
"type": "string",
"x-go-name": "HeadBranch"
},
"head_sha": {
"type": "string",
"x-go-name": "HeadSHA"
},
"id": {
"type": "integer",
"format": "int64",
"x-go-name": "ID"
},
"name": {
"type": "string",
"x-go-name": "Name"
},
"run_number": {
"type": "integer",
"format": "int64",
"x-go-name": "RunNumber"
},
"run_started_at": {
"type": "string",
"format": "date-time",
"x-go-name": "RunStartedAt"
},
"status": {
"type": "string",
"x-go-name": "Status"
},
"updated_at": {
"type": "string",
"format": "date-time",
"x-go-name": "UpdatedAt"
},
"url": {
"type": "string",
"x-go-name": "URL"
},
"workflow_id": {
"type": "string",
"x-go-name": "WorkflowID"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"ActionTaskResponse": {
"description": "ActionTaskResponse returns a ActionTask",
"type": "object",
"properties": {
"total_count": {
"type": "integer",
"format": "int64",
"x-go-name": "TotalCount"
},
"workflow_runs": {
"type": "array",
"items": {
"$ref": "#/definitions/ActionTask"
},
"x-go-name": "Entries"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"ActionVariable": {
"description": "ActionVariable return value of the query API",
"type": "object",
@ -25409,6 +25552,12 @@
}
}
},
"TasksList": {
"description": "TasksList",
"schema": {
"$ref": "#/definitions/ActionTaskResponse"
}
},
"Team": {
"description": "Team",
"schema": {