| 476 | } |
| 477 | |
| 478 | func GetJobs(client *api.Client, repo ghrepo.Interface, run *Run, attempt uint64) ([]Job, error) { |
| 479 | if run.Jobs != nil { |
| 480 | return run.Jobs, nil |
| 481 | } |
| 482 | |
| 483 | query := url.Values{} |
| 484 | query.Set("per_page", "100") |
| 485 | jobsPath := fmt.Sprintf("%s?%s", run.JobsURL, query.Encode()) |
| 486 | |
| 487 | if attempt > 0 { |
| 488 | jobsPath = fmt.Sprintf("repos/%s/actions/runs/%d/attempts/%d/jobs?%s", ghrepo.FullName(repo), run.ID, attempt, query.Encode()) |
| 489 | } |
| 490 | |
| 491 | for jobsPath != "" { |
| 492 | var resp JobsPayload |
| 493 | var err error |
| 494 | jobsPath, err = client.RESTWithNext(repo.RepoHost(), http.MethodGet, jobsPath, nil, &resp) |
| 495 | if err != nil { |
| 496 | run.Jobs = nil |
| 497 | return nil, err |
| 498 | } |
| 499 | |
| 500 | run.Jobs = append(run.Jobs, resp.Jobs...) |
| 501 | } |
| 502 | return run.Jobs, nil |
| 503 | } |
| 504 | |
| 505 | func GetJob(client *api.Client, repo ghrepo.Interface, jobID string) (*Job, error) { |
| 506 | path := fmt.Sprintf("repos/%s/actions/jobs/%s", ghrepo.FullName(repo), jobID) |