@@ -6,6 +6,7 @@ package repo
66import (
77 "errors"
88 "net/http"
9+ "strings"
910
1011 actions_model "code.gitea.io/gitea/models/actions"
1112 "code.gitea.io/gitea/models/db"
@@ -772,15 +773,16 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) {
772773 Doer : ctx .Doer ,
773774 Repo : ctx .Repo ,
774775 }, workflowID , opt .Ref , func (workflowDispatch * model.WorkflowDispatch , inputs map [string ]any ) error {
775- // TODO figure out why the inputs map is empty for url form encoding workaround
776- if opt .Inputs == nil {
776+ if strings .Contains (ctx .Req .Header .Get ("Content-Type" ), "form-urlencoded" ) {
777+ // The chi framework's "Binding" doesn't support to bind the form map values into a map[string]string
778+ // So we have to manually read the `inputs[key]` from the form
777779 for name , config := range workflowDispatch .Inputs {
778780 value := ctx .FormString ("inputs[" + name + "]" , config .Default )
779781 inputs [name ] = value
780782 }
781783 } else {
782784 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)?
785+ value , ok := opt .Inputs [name ]
784786 if ok {
785787 inputs [name ] = value
786788 } else {
@@ -790,6 +792,7 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) {
790792 }
791793 return nil
792794 })
795+
793796 if err != nil {
794797 if errors .Is (err , util .ErrNotExist ) {
795798 ctx .Error (http .StatusNotFound , "DispatchActionWorkflow" , err )
0 commit comments