Skip to content

Commit 3d77a3f

Browse files
committed
Refactor workflow dispatch
Signed-off-by: Bence Santha <[email protected]>
1 parent 0357003 commit 3d77a3f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

services/actions/workflow.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,19 @@ func DispatchActionWorkflow(ctx *context.APIContext, workflowID string, opt *api
194194
return
195195
}
196196
workflows, err := jobparser.Parse(content)
197-
if err != nil || len(workflows) == 0 {
197+
if err != nil {
198198
ctx.Error(http.StatusInternalServerError, "WorkflowParseError", err.Error())
199199
return
200200
}
201+
if len(workflows) == 0 {
202+
ctx.Error(http.StatusNotFound, "WorkflowNotFound", fmt.Sprintf("workflow '%s' is not found", workflowID))
203+
return
204+
}
201205
workflow = workflows[0]
202206
break
203207
}
204208
}
205209

206-
if workflow == nil {
207-
ctx.Error(http.StatusNotFound, "WorkflowNotFound", fmt.Sprintf("workflow '%s' is not found", workflowID))
208-
return
209-
}
210-
211210
// Process workflow inputs
212211
inputs := processWorkflowInputs(opt, &model.Workflow{
213212
RawOn: workflow.RawOn,
@@ -256,7 +255,8 @@ func DispatchActionWorkflow(ctx *context.APIContext, workflowID string, opt *api
256255
CreateCommitStatus(ctx, alljobs...)
257256
}
258257

259-
func processWorkflowInputs(opt *api.CreateActionWorkflowDispatch, workflow *model.Workflow) map[string]any {
258+
func processWorkflowInputs(opt *api.CreateActionWorkflowDispatch, workflow *model.Workflow) map[string]api.ActionWorkflowDispatchInput {
259+
// @see https://gitea.com/gitea/act/src/branch/main/pkg/jobparser/model.go#L207-L242
260260
inputs := make(map[string]any)
261261
if workflowDispatch := workflow.WorkflowDispatchConfig(); workflowDispatch != nil {
262262
for name, config := range workflowDispatch.Inputs {

0 commit comments

Comments
 (0)