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

Function GetWorkflows

pkg/cmd/workflow/shared/shared.go:57–94  ·  view source on GitHub ↗
(client *api.Client, repo ghrepo.Interface, limit int)

Source from the content-addressed store, hash-verified

55}
56
57func GetWorkflows(client *api.Client, repo ghrepo.Interface, limit int) ([]Workflow, error) {
58 perPage := limit
59 page := 1
60 if limit > 100 || limit == 0 {
61 perPage = 100
62 }
63
64 workflows := []Workflow{}
65
66 for {
67 if limit > 0 && len(workflows) == limit {
68 break
69 }
70 var result WorkflowsPayload
71
72 path := fmt.Sprintf("repos/%s/actions/workflows?per_page=%d&page=%d", ghrepo.FullName(repo), perPage, page)
73
74 err := client.REST(repo.RepoHost(), "GET", path, nil, &result)
75 if err != nil {
76 return nil, err
77 }
78
79 for _, workflow := range result.Workflows {
80 workflows = append(workflows, workflow)
81 if limit > 0 && len(workflows) == limit {
82 break
83 }
84 }
85
86 if len(result.Workflows) < perPage {
87 break
88 }
89
90 page++
91 }
92
93 return workflows, nil
94}
95
96type FilteredAllError struct {
97 error

Callers 4

listRunFunction · 0.92
TestGetWorkflowsFunction · 0.85
getWorkflowsByNameFunction · 0.85
ResolveWorkflowFunction · 0.85

Calls 3

FullNameFunction · 0.92
RESTMethod · 0.65
RepoHostMethod · 0.65

Tested by 1

TestGetWorkflowsFunction · 0.68