GetRunsWithFilter fetches 50 runs from the API and filters them in-memory
(client *api.Client, repo ghrepo.Interface, opts *FilterOptions, limit int, f func(Run) bool)
| 342 | |
| 343 | // GetRunsWithFilter fetches 50 runs from the API and filters them in-memory |
| 344 | func GetRunsWithFilter(client *api.Client, repo ghrepo.Interface, opts *FilterOptions, limit int, f func(Run) bool) ([]Run, error) { |
| 345 | runs, err := GetRuns(client, repo, opts, 50) |
| 346 | if err != nil { |
| 347 | return nil, err |
| 348 | } |
| 349 | |
| 350 | var filtered []Run |
| 351 | for _, run := range runs.WorkflowRuns { |
| 352 | if f(run) { |
| 353 | filtered = append(filtered, run) |
| 354 | } |
| 355 | if len(filtered) == limit { |
| 356 | break |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | return filtered, nil |
| 361 | } |
| 362 | |
| 363 | func GetRuns(client *api.Client, repo ghrepo.Interface, opts *FilterOptions, limit int) (*RunsPayload, error) { |
| 364 | path := fmt.Sprintf("repos/%s/actions/runs", ghrepo.FullName(repo)) |