Helper functions for consolidated actions tools
(ctx context.Context, client *github.Client, owner, repo, resourceID string)
| 773 | // Helper functions for consolidated actions tools |
| 774 | |
| 775 | func getWorkflow(ctx context.Context, client *github.Client, owner, repo, resourceID string) (*mcp.CallToolResult, any, error) { |
| 776 | var workflow *github.Workflow |
| 777 | var resp *github.Response |
| 778 | var err error |
| 779 | |
| 780 | if workflowIDInt, parseErr := strconv.ParseInt(resourceID, 10, 64); parseErr == nil { |
| 781 | workflow, resp, err = client.Actions.GetWorkflowByID(ctx, owner, repo, workflowIDInt) |
| 782 | } else { |
| 783 | workflow, resp, err = client.Actions.GetWorkflowByFileName(ctx, owner, repo, resourceID) |
| 784 | } |
| 785 | |
| 786 | if err != nil { |
| 787 | return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to get workflow", resp, err), nil, nil |
| 788 | } |
| 789 | |
| 790 | defer func() { _ = resp.Body.Close() }() |
| 791 | r, err := json.Marshal(workflow) |
| 792 | if err != nil { |
| 793 | return nil, nil, fmt.Errorf("failed to marshal workflow: %w", err) |
| 794 | } |
| 795 | |
| 796 | return utils.NewToolResultText(string(r)), nil, nil |
| 797 | } |
| 798 | |
| 799 | func getWorkflowRun(ctx context.Context, client *github.Client, owner, repo string, resourceID int64) (*mcp.CallToolResult, any, error) { |
| 800 | workflowRun, resp, err := client.Actions.GetWorkflowRunByID(ctx, owner, repo, resourceID) |
no test coverage detected