Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove WorkflowAPI interface because these route handlers are not reused
  • Loading branch information
wxiaoguang committed Feb 10, 2025
commit aa80af03f61b77b48dffb854761120141f7ce5ed
35 changes: 11 additions & 24 deletions routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,21 +915,6 @@ func Routes() *web.Router {
})
}

addActionsWorkflowRoutes := func(
m *web.Router,
actw actions.WorkflowAPI,
) {
m.Group("/actions", func() {
m.Group("/workflows", func() {
m.Get("", reqToken(), actw.ListRepositoryWorkflows)
m.Get("/{workflow_id}", reqToken(), actw.GetWorkflow)
m.Put("/{workflow_id}/disable", reqToken(), reqRepoWriter(unit.TypeActions), actw.DisableWorkflow)
m.Post("/{workflow_id}/dispatches", reqToken(), reqRepoWriter(unit.TypeActions), bind(api.CreateActionWorkflowDispatch{}), actw.DispatchWorkflow)
m.Put("/{workflow_id}/enable", reqToken(), reqRepoWriter(unit.TypeActions), actw.EnableWorkflow)
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeActions))
})
}

m.Group("", func() {
// Miscellaneous (no scope required)
if setting.API.EnableSwagger {
Expand Down Expand Up @@ -1170,15 +1155,17 @@ func Routes() *web.Router {
m.Post("/accept", repo.AcceptTransfer)
m.Post("/reject", repo.RejectTransfer)
}, reqToken())
addActionsRoutes(
m,
reqOwner(),
repo.NewAction(),
)
addActionsWorkflowRoutes(
m,
repo.NewActionWorkflow(),
)

addActionsRoutes(m, reqOwner(), repo.NewAction()) // it adds the routes for secrets/variables and runner management

m.Group("/actions/workflows", func() {
m.Get("", reqToken(), repo.ActionsListRepositoryWorkflows)
m.Get("/{workflow_id}", reqToken(), repo.ActionsGetWorkflow)
m.Put("/{workflow_id}/disable", reqToken(), reqRepoWriter(unit.TypeActions), repo.ActionsDisableWorkflow)
m.Post("/{workflow_id}/dispatches", reqToken(), reqRepoWriter(unit.TypeActions), bind(api.CreateActionWorkflowDispatch{}), repo.ActionsDispatchWorkflow)
m.Put("/{workflow_id}/enable", reqToken(), reqRepoWriter(unit.TypeActions), repo.ActionsEnableWorkflow)
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeActions))

m.Group("/hooks/git", func() {
m.Combo("").Get(repo.ListGitHooks)
m.Group("/{id}", func() {
Expand Down
28 changes: 10 additions & 18 deletions routers/api/v1/repo/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,16 +585,8 @@ func ListActionTasks(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, &res)
}

// ActionWorkflow implements actions_service.WorkflowAPI
type ActionWorkflow struct{}

// NewActionWorkflow creates a new ActionWorkflow service
func NewActionWorkflow() actions_service.WorkflowAPI {
return ActionWorkflow{}
}

func (a ActionWorkflow) ListRepositoryWorkflows(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows repository ListRepositoryWorkflows
func ActionsListRepositoryWorkflows(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows repository ActionsListRepositoryWorkflows
// ---
// summary: List repository workflows
// produces:
Expand Down Expand Up @@ -633,8 +625,8 @@ func (a ActionWorkflow) ListRepositoryWorkflows(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, &api.ActionWorkflowResponse{Workflows: workflows, TotalCount: int64(len(workflows))})
}

func (a ActionWorkflow) GetWorkflow(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id} repository GetWorkflow
func ActionsGetWorkflow(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id} repository ActionsGetWorkflow
// ---
// summary: Get a workflow
// produces:
Expand Down Expand Up @@ -689,8 +681,8 @@ func (a ActionWorkflow) GetWorkflow(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, workflow)
}

func (a ActionWorkflow) DisableWorkflow(ctx *context.APIContext) {
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable repository DisableWorkflow
func ActionsDisableWorkflow(ctx *context.APIContext) {
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable repository ActionsDisableWorkflow
// ---
// summary: Disable a workflow
// produces:
Expand Down Expand Up @@ -738,8 +730,8 @@ func (a ActionWorkflow) DisableWorkflow(ctx *context.APIContext) {
ctx.Status(http.StatusNoContent)
}

func (a ActionWorkflow) DispatchWorkflow(ctx *context.APIContext) {
// swagger:operation POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches repository DispatchWorkflow
func ActionsDispatchWorkflow(ctx *context.APIContext) {
// swagger:operation POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches repository ActionsDispatchWorkflow
// ---
// summary: Create a workflow dispatch event
// produces:
Expand Down Expand Up @@ -828,8 +820,8 @@ func (a ActionWorkflow) DispatchWorkflow(ctx *context.APIContext) {
ctx.Status(http.StatusNoContent)
}

func (a ActionWorkflow) EnableWorkflow(ctx *context.APIContext) {
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable repository EnableWorkflow
func ActionsEnableWorkflow(ctx *context.APIContext) {
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable repository ActionsEnableWorkflow
// ---
// summary: Enable a workflow
// produces:
Expand Down
20 changes: 0 additions & 20 deletions services/actions/workflow_interface.go

This file was deleted.

Loading