Feature: Support workflow event dispatch via API (#32059)

ref: https://github.com/go-gitea/gitea/issues/31765

---------

Signed-off-by: Bence Santha <git@santha.eu>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
This commit is contained in:
Bence Sántha 2025-02-09 22:23:57 +01:00 committed by GitHub
parent 06088ec672
commit 523751dc82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 1685 additions and 137 deletions

View file

@ -915,6 +915,21 @@ 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 {
@ -1160,6 +1175,10 @@ func Routes() *web.Router {
reqOwner(),
repo.NewAction(),
)
addActionsWorkflowRoutes(
m,
repo.NewActionWorkflow(),
)
m.Group("/hooks/git", func() {
m.Combo("").Get(repo.ListGitHooks)
m.Group("/{id}", func() {