(ctx context.Context, client *github.Client, args map[string]any, owner, repo, resourceID string, pagination PaginationParams)
| 843 | } |
| 844 | |
| 845 | func listWorkflowRuns(ctx context.Context, client *github.Client, args map[string]any, owner, repo, resourceID string, pagination PaginationParams) (*mcp.CallToolResult, any, error) { |
| 846 | filterArgs, err := OptionalParam[map[string]any](args, "workflow_runs_filter") |
| 847 | if err != nil { |
| 848 | return utils.NewToolResultError(err.Error()), nil, nil |
| 849 | } |
| 850 | |
| 851 | filterArgsTyped := make(map[string]string) |
| 852 | for k, v := range filterArgs { |
| 853 | if strVal, ok := v.(string); ok { |
| 854 | filterArgsTyped[k] = strVal |
| 855 | } else { |
| 856 | filterArgsTyped[k] = "" |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | listWorkflowRunsOptions := &github.ListWorkflowRunsOptions{ |
| 861 | Actor: filterArgsTyped["actor"], |
| 862 | Branch: filterArgsTyped["branch"], |
| 863 | Event: filterArgsTyped["event"], |
| 864 | Status: filterArgsTyped["status"], |
| 865 | ListOptions: github.ListOptions{ |
| 866 | Page: pagination.Page, |
| 867 | PerPage: pagination.PerPage, |
| 868 | }, |
| 869 | } |
| 870 | |
| 871 | var workflowRuns *github.WorkflowRuns |
| 872 | var resp *github.Response |
| 873 | |
| 874 | if resourceID == "" { |
| 875 | workflowRuns, resp, err = client.Actions.ListRepositoryWorkflowRuns(ctx, owner, repo, listWorkflowRunsOptions) |
| 876 | } else if workflowIDInt, parseErr := strconv.ParseInt(resourceID, 10, 64); parseErr == nil { |
| 877 | workflowRuns, resp, err = client.Actions.ListWorkflowRunsByID(ctx, owner, repo, workflowIDInt, listWorkflowRunsOptions) |
| 878 | } else { |
| 879 | workflowRuns, resp, err = client.Actions.ListWorkflowRunsByFileName(ctx, owner, repo, resourceID, listWorkflowRunsOptions) |
| 880 | } |
| 881 | |
| 882 | if err != nil { |
| 883 | return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to list workflow runs", resp, err), nil, nil |
| 884 | } |
| 885 | |
| 886 | defer func() { _ = resp.Body.Close() }() |
| 887 | r, err := json.Marshal(workflowRuns) |
| 888 | if err != nil { |
| 889 | return nil, nil, fmt.Errorf("failed to marshal workflow runs: %w", err) |
| 890 | } |
| 891 | |
| 892 | return utils.NewToolResultText(string(r)), nil, nil |
| 893 | } |
| 894 | |
| 895 | func listWorkflowJobs(ctx context.Context, client *github.Client, args map[string]any, owner, repo string, resourceID int64, pagination PaginationParams) (*mcp.CallToolResult, any, error) { |
| 896 | filterArgs, err := OptionalParam[map[string]any](args, "workflow_jobs_filter") |
no test coverage detected