-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Support workflow event dispatch via API #32059
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Bence Santha <[email protected]>
Signed-off-by: Bence Santha <[email protected]>
Signed-off-by: Bence Santha <[email protected]>
Signed-off-by: Bence Santha <[email protected]>
Signed-off-by: Bence Santha <[email protected]>
Signed-off-by: Bence Santha <[email protected]>
Signed-off-by: Bence Santha <[email protected]>
Signed-off-by: Bence Santha <[email protected]>
services/actions/workflow.go
Outdated
return | ||
} | ||
workflows, err := jobparser.Parse(content) | ||
if err != nil || len(workflows) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will panic if err == nil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it by adding a check for both the error and the empty workflows case. Now, it handles the scenario where len(workflows) == 0
after confirming that err == nil
, preventing a potential panic.
Signed-off-by: Bence Santha <[email protected]>
m.Put("/{workflow_id}/disable", reqToken(), reqChecker, actw.DisableWorkflow) | ||
m.Post("/{workflow_id}/dispatches", reqToken(), reqChecker, bind(api.CreateActionWorkflowDispatch{}), actw.DispatchWorkflow) | ||
m.Put("/{workflow_id}/enable", reqToken(), reqChecker, actw.EnableWorkflow) | ||
}, context.ReferencesGitRepo(), reqRepoWriter(unit.TypeActions)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GET
methods just need reqRepoReader(unit.TypeActions)
, POST
and PUT
needs reqRepoWriter(unit.TypeActions)
.
@@ -1107,6 +1123,11 @@ func Routes() *web.Router { | |||
reqOwner(), | |||
repo.NewAction(), | |||
) | |||
addActionsWorkflowRoutes( | |||
m, | |||
reqRepoWriter(unit.TypeActions), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second parameter seems unnecessary.
ref: #31765