Skip to content

Commit 7c2a6e0

Browse files
committed
do not process inputs if workflowDispatch is nil
1 parent d404552 commit 7c2a6e0

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed

routers/api/v1/repo/action.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -772,21 +772,19 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) {
772772
Doer: ctx.Doer,
773773
Repo: ctx.Repo,
774774
}, workflowID, opt.Ref, func(workflowDispatch *model.WorkflowDispatch, inputs map[string]any) error {
775-
if workflowDispatch != nil {
776-
// TODO figure out why the inputs map is empty for url form encoding workaround
777-
if opt.Inputs == nil {
778-
for name, config := range workflowDispatch.Inputs {
779-
value := ctx.FormString("inputs["+name+"]", config.Default)
775+
// TODO figure out why the inputs map is empty for url form encoding workaround
776+
if opt.Inputs == nil {
777+
for name, config := range workflowDispatch.Inputs {
778+
value := ctx.FormString("inputs["+name+"]", config.Default)
779+
inputs[name] = value
780+
}
781+
} else {
782+
for name, config := range workflowDispatch.Inputs {
783+
value, ok := opt.Inputs[name] // FIXME: the input value is "any", does GitHub Actions really work with "any" (eg: bool)?
784+
if ok {
780785
inputs[name] = value
781-
}
782-
} else {
783-
for name, config := range workflowDispatch.Inputs {
784-
value, ok := opt.Inputs[name] // FIXME: the input value is "any", does GitHub Actions really work with "any" (eg: bool)?
785-
if ok {
786-
inputs[name] = value
787-
} else {
788-
inputs[name] = config.Default
789-
}
786+
} else {
787+
inputs[name] = config.Default
790788
}
791789
}
792790
}

routers/web/repo/actions/view.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -788,16 +788,14 @@ func Run(ctx *context_module.Context) {
788788
return
789789
}
790790
err := actions_service.DispatchActionWorkflow(ctx, workflowID, ref, func(workflowDispatch *model.WorkflowDispatch, inputs map[string]any) error {
791-
if workflowDispatch != nil {
792-
for name, config := range workflowDispatch.Inputs {
793-
value := ctx.Req.PostFormValue(name)
794-
if config.Type == "boolean" {
795-
inputs[name] = strconv.FormatBool(ctx.FormBool(name))
796-
} else if value != "" {
797-
inputs[name] = value
798-
} else {
799-
inputs[name] = config.Default
800-
}
791+
for name, config := range workflowDispatch.Inputs {
792+
value := ctx.Req.PostFormValue(name)
793+
if config.Type == "boolean" {
794+
inputs[name] = strconv.FormatBool(ctx.FormBool(name))
795+
} else if value != "" {
796+
inputs[name] = value
797+
} else {
798+
inputs[name] = config.Default
801799
}
802800
}
803801
return nil

services/actions/workflow.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,10 @@ func DispatchActionWorkflow(ctx *context.Context, workflowID, ref string, proces
221221
RawOn: workflows[0].RawOn,
222222
}
223223
inputsWithDefaults := make(map[string]any)
224-
workflowDispatch := workflow.WorkflowDispatchConfig()
225-
if err := processInputs(workflowDispatch, inputsWithDefaults); err != nil {
226-
return err
224+
if workflowDispatch := workflow.WorkflowDispatchConfig(); workflowDispatch != nil {
225+
if err = processInputs(workflowDispatch, inputsWithDefaults); err != nil {
226+
return err
227+
}
227228
}
228229

229230
// ctx.Req.PostForm -> WorkflowDispatchPayload.Inputs -> ActionRun.EventPayload -> runner: ghc.Event

0 commit comments

Comments
 (0)