MCPcopy Create free account
hub / github.com/cli/cli / GetWorkflows

Function GetWorkflows

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

Source from the content-addressed store, hash-verified

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

Callers 4

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

Calls 7

JoinPathFunction · 0.92
SetQueryMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65

Tested by 1

TestGetWorkflowsFunction · 0.68