MCPcopy
hub / github.com/github/github-mcp-server / cancelWorkflowRun

Function cancelWorkflowRun

pkg/github/actions.go:1103–1126  ·  view source on GitHub ↗
(ctx context.Context, client *github.Client, owner, repo string, runID int64)

Source from the content-addressed store, hash-verified

1101}
1102
1103func cancelWorkflowRun(ctx context.Context, client *github.Client, owner, repo string, runID int64) (*mcp.CallToolResult, any, error) {
1104 resp, err := client.Actions.CancelWorkflowRunByID(ctx, owner, repo, runID)
1105 if err != nil {
1106 var acceptedErr *github.AcceptedError
1107 if !errors.As(err, &acceptedErr) {
1108 return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to cancel workflow run", resp, err), nil, nil
1109 }
1110 }
1111 defer func() { _ = resp.Body.Close() }()
1112
1113 result := map[string]any{
1114 "message": "Workflow run has been cancelled",
1115 "run_id": runID,
1116 "status": resp.Status,
1117 "status_code": resp.StatusCode,
1118 }
1119
1120 r, err := json.Marshal(result)
1121 if err != nil {
1122 return nil, nil, fmt.Errorf("failed to marshal response: %w", err)
1123 }
1124
1125 return utils.NewToolResultText(string(r)), nil, nil
1126}
1127
1128func deleteWorkflowRunLogs(ctx context.Context, client *github.Client, owner, repo string, runID int64) (*mcp.CallToolResult, any, error) {
1129 resp, err := client.Actions.DeleteWorkflowRunLogs(ctx, owner, repo, runID)

Callers 1

ActionsRunTriggerFunction · 0.85

Calls 3

NewToolResultTextFunction · 0.92
AsMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected