@@ -6,6 +6,7 @@ package repo
6
6
import (
7
7
"errors"
8
8
"net/http"
9
+ "strings"
9
10
10
11
actions_model "code.gitea.io/gitea/models/actions"
11
12
"code.gitea.io/gitea/models/db"
@@ -772,15 +773,16 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) {
772
773
Doer : ctx .Doer ,
773
774
Repo : ctx .Repo ,
774
775
}, 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
777
779
for name , config := range workflowDispatch .Inputs {
778
780
value := ctx .FormString ("inputs[" + name + "]" , config .Default )
779
781
inputs [name ] = value
780
782
}
781
783
} else {
782
784
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 ]
784
786
if ok {
785
787
inputs [name ] = value
786
788
} else {
@@ -790,6 +792,7 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) {
790
792
}
791
793
return nil
792
794
})
795
+
793
796
if err != nil {
794
797
if errors .Is (err , util .ErrNotExist ) {
795
798
ctx .Error (http .StatusNotFound , "DispatchActionWorkflow" , err )
0 commit comments