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

Function GetRuns

pkg/cmd/run/shared/shared.go:368–446  ·  view source on GitHub ↗
(client *api.Client, repo ghrepo.Interface, opts *FilterOptions, limit int)

Source from the content-addressed store, hash-verified

366}
367
368func GetRuns(client *api.Client, repo ghrepo.Interface, opts *FilterOptions, limit int) (*RunsPayload, error) {
369 u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "runs")
370 if err != nil {
371 return nil, err
372 }
373 if opts != nil && opts.WorkflowID > 0 {
374 u, err = safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "workflows", strconv.FormatInt(opts.WorkflowID, 10), "runs")
375 if err != nil {
376 return nil, err
377 }
378 }
379
380 perPage := limit
381 if limit > 100 {
382 perPage = 100
383 }
384 u.SetQuery("per_page", strconv.Itoa(perPage))
385 u.SetQuery("exclude_pull_requests", "true") // significantly reduces payload size
386
387 if opts != nil {
388 if opts.Branch != "" {
389 u.SetQuery("branch", opts.Branch)
390 }
391 if opts.Actor != "" {
392 u.SetQuery("actor", opts.Actor)
393 }
394 if opts.Status != "" {
395 u.SetQuery("status", opts.Status)
396 }
397 if opts.Event != "" {
398 u.SetQuery("event", opts.Event)
399 }
400 if opts.Created != "" {
401 u.SetQuery("created", opts.Created)
402 }
403 if opts.Commit != "" {
404 u.SetQuery("head_sha", opts.Commit)
405 }
406 }
407 var pageURL safeurl.SafeURL = u
408
409 var result *RunsPayload
410
411pagination:
412 for pageURL.String() != "" {
413 var response RunsPayload
414 next, err := client.RESTWithNext(repo.RepoHost(), "GET", pageURL.String(), nil, &response)
415 if err != nil {
416 return nil, err
417 }
418 pageURL = safeurl.NewImmutableSafeURL(next)
419
420 if result == nil {
421 result = &response
422 if len(result.WorkflowRuns) == limit {
423 break pagination
424 }
425 } else {

Callers 3

runDeleteFunction · 0.92
runViewFunction · 0.92
GetRunsWithFilterFunction · 0.85

Calls 9

StringMethod · 0.95
JoinPathFunction · 0.92
NewImmutableSafeURLFunction · 0.92
preloadWorkflowNamesFunction · 0.85
SetQueryMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTWithNextMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected