mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-15 10:43:21 +02:00
add new api sub path
This commit is contained in:
parent
80585adab4
commit
028df22aad
@ -89,5 +89,5 @@ func ListWorkflowRuns(ctx *context.APIContext) {
|
|||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
shared.ListRuns(ctx, 0, 0)
|
shared.ListRuns(ctx, 0, 0, "")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1166,6 +1166,7 @@ func Routes() *web.Router {
|
|||||||
m.Group("/actions/workflows", func() {
|
m.Group("/actions/workflows", func() {
|
||||||
m.Get("", repo.ActionsListRepositoryWorkflows)
|
m.Get("", repo.ActionsListRepositoryWorkflows)
|
||||||
m.Get("/{workflow_id}", repo.ActionsGetWorkflow)
|
m.Get("/{workflow_id}", repo.ActionsGetWorkflow)
|
||||||
|
m.Get("/{workflow_id}/runs", repo.ActionsListWorkflowRuns)
|
||||||
m.Put("/{workflow_id}/disable", reqRepoWriter(unit.TypeActions), repo.ActionsDisableWorkflow)
|
m.Put("/{workflow_id}/disable", reqRepoWriter(unit.TypeActions), repo.ActionsDisableWorkflow)
|
||||||
m.Put("/{workflow_id}/enable", reqRepoWriter(unit.TypeActions), repo.ActionsEnableWorkflow)
|
m.Put("/{workflow_id}/enable", reqRepoWriter(unit.TypeActions), repo.ActionsEnableWorkflow)
|
||||||
m.Post("/{workflow_id}/dispatches", reqRepoWriter(unit.TypeActions), bind(api.CreateActionWorkflowDispatch{}), repo.ActionsDispatchWorkflow)
|
m.Post("/{workflow_id}/dispatches", reqRepoWriter(unit.TypeActions), bind(api.CreateActionWorkflowDispatch{}), repo.ActionsDispatchWorkflow)
|
||||||
|
|||||||
@ -679,7 +679,7 @@ func (Action) ListWorkflowRuns(ctx *context.APIContext) {
|
|||||||
// "$ref": "#/responses/error"
|
// "$ref": "#/responses/error"
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
shared.ListRuns(ctx, ctx.Org.Organization.ID, 0)
|
shared.ListRuns(ctx, ctx.Org.Organization.ID, 0, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ actions_service.API = new(Action)
|
var _ actions_service.API = new(Action)
|
||||||
|
|||||||
@ -781,7 +781,7 @@ func (Action) ListWorkflowRuns(ctx *context.APIContext) {
|
|||||||
|
|
||||||
repoID := ctx.Repo.Repository.ID
|
repoID := ctx.Repo.Repository.ID
|
||||||
|
|
||||||
shared.ListRuns(ctx, 0, repoID)
|
shared.ListRuns(ctx, 0, repoID, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ actions_service.API = new(Action)
|
var _ actions_service.API = new(Action)
|
||||||
@ -952,6 +952,77 @@ func ActionsGetWorkflow(ctx *context.APIContext) {
|
|||||||
ctx.JSON(http.StatusOK, workflow)
|
ctx.JSON(http.StatusOK, workflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ActionsListWorkflowRuns(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs repository ActionsListWorkflowRuns
|
||||||
|
// ---
|
||||||
|
// summary: List runs for a workflow
|
||||||
|
// 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: workflow_id
|
||||||
|
// in: path
|
||||||
|
// description: id of the workflow
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: event
|
||||||
|
// in: query
|
||||||
|
// description: workflow event name
|
||||||
|
// type: string
|
||||||
|
// required: false
|
||||||
|
// - name: branch
|
||||||
|
// in: query
|
||||||
|
// description: workflow branch
|
||||||
|
// type: string
|
||||||
|
// required: false
|
||||||
|
// - name: status
|
||||||
|
// in: query
|
||||||
|
// description: workflow status (pending, queued, in_progress, failure, success, skipped)
|
||||||
|
// type: string
|
||||||
|
// required: false
|
||||||
|
// - name: actor
|
||||||
|
// in: query
|
||||||
|
// description: triggered by user
|
||||||
|
// type: string
|
||||||
|
// required: false
|
||||||
|
// - name: head_sha
|
||||||
|
// in: query
|
||||||
|
// description: triggering sha of the workflow run
|
||||||
|
// type: string
|
||||||
|
// required: false
|
||||||
|
// - name: page
|
||||||
|
// in: query
|
||||||
|
// description: page number of results to return (1-based)
|
||||||
|
// type: integer
|
||||||
|
// - name: limit
|
||||||
|
// in: query
|
||||||
|
// description: page size of results
|
||||||
|
// type: integer
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/WorkflowRunsList"
|
||||||
|
// "400":
|
||||||
|
// "$ref": "#/responses/error"
|
||||||
|
// "403":
|
||||||
|
// "$ref": "#/responses/forbidden"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
|
workflowID := ctx.PathParam("workflow_id")
|
||||||
|
repoID := ctx.Repo.Repository.ID
|
||||||
|
|
||||||
|
shared.ListRuns(ctx, 0, repoID, workflowID)
|
||||||
|
}
|
||||||
|
|
||||||
func ActionsDisableWorkflow(ctx *context.APIContext) {
|
func ActionsDisableWorkflow(ctx *context.APIContext) {
|
||||||
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable repository ActionsDisableWorkflow
|
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable repository ActionsDisableWorkflow
|
||||||
// ---
|
// ---
|
||||||
|
|||||||
@ -117,8 +117,9 @@ func convertToInternal(s string) ([]actions_model.Status, error) {
|
|||||||
// ownerID == 0 and repoID != 0 means all runs for the given repo
|
// ownerID == 0 and repoID != 0 means all runs for the given repo
|
||||||
// ownerID != 0 and repoID == 0 means all runs for the given user/org
|
// ownerID != 0 and repoID == 0 means all runs for the given user/org
|
||||||
// ownerID != 0 and repoID != 0 undefined behavior
|
// ownerID != 0 and repoID != 0 undefined behavior
|
||||||
|
// workflowID filters runs by workflow file name (e.g. "build.yml"), empty means no filter
|
||||||
// Access rights are checked at the API route level
|
// Access rights are checked at the API route level
|
||||||
func ListRuns(ctx *context.APIContext, ownerID, repoID int64) {
|
func ListRuns(ctx *context.APIContext, ownerID, repoID int64, workflowID string) {
|
||||||
if ownerID != 0 && repoID != 0 {
|
if ownerID != 0 && repoID != 0 {
|
||||||
setting.PanicInDevOrTesting("ownerID and repoID should not be both set")
|
setting.PanicInDevOrTesting("ownerID and repoID should not be both set")
|
||||||
}
|
}
|
||||||
@ -126,6 +127,7 @@ func ListRuns(ctx *context.APIContext, ownerID, repoID int64) {
|
|||||||
opts := actions_model.FindRunOptions{
|
opts := actions_model.FindRunOptions{
|
||||||
OwnerID: ownerID,
|
OwnerID: ownerID,
|
||||||
RepoID: repoID,
|
RepoID: repoID,
|
||||||
|
WorkflowID: workflowID,
|
||||||
ListOptions: listOptions,
|
ListOptions: listOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -407,7 +407,7 @@ func ListWorkflowRuns(ctx *context.APIContext) {
|
|||||||
// "$ref": "#/responses/error"
|
// "$ref": "#/responses/error"
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
shared.ListRuns(ctx, ctx.Doer.ID, 0)
|
shared.ListRuns(ctx, ctx.Doer.ID, 0, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListWorkflowJobs lists workflow jobs
|
// ListWorkflowJobs lists workflow jobs
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user