Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/github/__toolsnaps__/actions_run_trigger.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"properties": {
"inputs": {
"description": "Inputs the workflow accepts. Only used for 'run_workflow' method.",
"properties": {},
"type": "object"
},
"method": {
Expand Down
9 changes: 4 additions & 5 deletions pkg/github/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ func ActionsRunTrigger(t translations.TranslationHelperFunc) inventory.ServerToo
"inputs": {
Type: "object",
Description: "Inputs the workflow accepts. Only used for 'run_workflow' method.",
Properties: map[string]*jsonschema.Schema{},
},
"run_id": {
Type: "number",
Expand Down Expand Up @@ -574,11 +575,9 @@ func ActionsRunTrigger(t translations.TranslationHelperFunc) inventory.ServerToo
runID, _ := OptionalIntParam(args, "run_id")

// Get optional inputs parameter
var inputs map[string]any
if requestInputs, ok := args["inputs"]; ok {
if inputsMap, ok := requestInputs.(map[string]any); ok {
inputs = inputsMap
}
inputs, err := OptionalParam[map[string]any](args, "inputs")
if err != nil {
return utils.NewToolResultError(err.Error()), nil, nil
}
Comment thread
kerobbi marked this conversation as resolved.

// Validate required parameters based on action type
Expand Down
31 changes: 31 additions & 0 deletions pkg/github/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,37 @@ func Test_ActionsRunTrigger_RunWorkflow(t *testing.T) {
expectError: true,
expectedErrMsg: "ref is required for run_workflow action",
},
{
name: "successful workflow run with inputs",
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
PostReposActionsWorkflowsDispatchesByOwnerByRepoByWorkflowID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusNoContent)
}),
}),
requestArgs: map[string]any{
"method": "run_workflow",
"owner": "owner",
"repo": "repo",
"workflow_id": "12345",
"ref": "main",
"inputs": map[string]any{"FIELD1": "value1", "FIELD2": "value2"},
},
expectError: false,
},
{
name: "invalid inputs type returns error",
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}),
requestArgs: map[string]any{
"method": "run_workflow",
"owner": "owner",
"repo": "repo",
"workflow_id": "12345",
"ref": "main",
"inputs": "not a map",
},
expectError: true,
expectedErrMsg: "parameter inputs is not of type map[string]interface {}, is string",
},
}

for _, tc := range tests {
Expand Down
Loading