MCPcopy Index your code
hub / github.com/cli/cli / GetWorkflowContent

Function GetWorkflowContent

pkg/cmd/workflow/shared/shared.go:235–263  ·  view source on GitHub ↗
(client *api.Client, repo ghrepo.Interface, workflow Workflow, ref string)

Source from the content-addressed store, hash-verified

233}
234
235func GetWorkflowContent(client *api.Client, repo ghrepo.Interface, workflow Workflow, ref string) ([]byte, error) {
236 path := fmt.Sprintf("repos/%s/contents/%s", ghrepo.FullName(repo), workflow.Path)
237 if ref != "" {
238 q := fmt.Sprintf("?ref=%s", url.QueryEscape(ref))
239 path = path + q
240 }
241
242 type Result struct {
243 Content string
244 }
245
246 var result Result
247 err := client.REST(repo.RepoHost(), "GET", path, nil, &result)
248 if err != nil {
249 return nil, err
250 }
251
252 decoded, err := base64.StdEncoding.DecodeString(result.Content)
253 if err != nil {
254 return nil, fmt.Errorf("failed to decode workflow file: %w", err)
255 }
256
257 sanitized, err := io.ReadAll(transform.NewReader(bytes.NewReader(decoded), &asciisanitizer.Sanitizer{}))
258 if err != nil {
259 return nil, err
260 }
261
262 return sanitized, nil
263}

Callers 2

viewWorkflowContentFunction · 0.92
runRunFunction · 0.92

Calls 4

FullNameFunction · 0.92
RESTMethod · 0.65
RepoHostMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected