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

Function GetRuns

pkg/cmd/run/shared/shared.go:368–443  ·  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 := min(limit, 100)
381 u.SetQuery("per_page", strconv.Itoa(perPage))
382 u.SetQuery("exclude_pull_requests", "true") // significantly reduces payload size
383
384 if opts != nil {
385 if opts.Branch != "" {
386 u.SetQuery("branch", opts.Branch)
387 }
388 if opts.Actor != "" {
389 u.SetQuery("actor", opts.Actor)
390 }
391 if opts.Status != "" {
392 u.SetQuery("status", opts.Status)
393 }
394 if opts.Event != "" {
395 u.SetQuery("event", opts.Event)
396 }
397 if opts.Created != "" {
398 u.SetQuery("created", opts.Created)
399 }
400 if opts.Commit != "" {
401 u.SetQuery("head_sha", opts.Commit)
402 }
403 }
404 var pageURL safeurl.SafeURL = u
405
406 var result *RunsPayload
407
408pagination:
409 for pageURL.String() != "" {
410 var response RunsPayload
411 next, err := client.RESTWithNext(repo.RepoHost(), "GET", pageURL.String(), nil, &response)
412 if err != nil {
413 return nil, err
414 }
415 pageURL = safeurl.NewImmutableSafeURL(next)
416
417 if result == nil {
418 result = &response
419 if len(result.WorkflowRuns) == limit {
420 break pagination
421 }
422 } else {
423 for _, run := range response.WorkflowRuns {
424 result.WorkflowRuns = append(result.WorkflowRuns, run)
425 if len(result.WorkflowRuns) == limit {

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