| 352 | } |
| 353 | |
| 354 | async runnerJob({ runnerId, status = 'queued' } = {}) { |
| 355 | const { owner, repo } = ownerRepo({ uri: this.repo }); |
| 356 | const octokitClient = octokit(this.token, this.repo, logger); |
| 357 | |
| 358 | if (status === 'running') status = 'in_progress'; |
| 359 | |
| 360 | const workflowRuns = await octokitClient.paginate( |
| 361 | octokitClient.actions.listWorkflowRunsForRepo, |
| 362 | { owner, repo, status } |
| 363 | ); |
| 364 | |
| 365 | let runJobs = await Promise.all( |
| 366 | workflowRuns.map( |
| 367 | async ({ id }) => |
| 368 | await octokitClient.paginate( |
| 369 | octokitClient.actions.listJobsForWorkflowRun, |
| 370 | { owner, repo, run_id: id, status } |
| 371 | ) |
| 372 | ) |
| 373 | ); |
| 374 | |
| 375 | runJobs = [].concat.apply([], runJobs); |
| 376 | |
| 377 | for (const job of runJobs) { |
| 378 | const { id } = job; |
| 379 | |
| 380 | while (!job.runner_id) { |
| 381 | const { |
| 382 | data: { runner_id: jobRunnerId } |
| 383 | } = await octokitClient.actions.getJobForWorkflowRun({ |
| 384 | owner, |
| 385 | repo, |
| 386 | job_id: id |
| 387 | }); |
| 388 | |
| 389 | job.runner_id = jobRunnerId; |
| 390 | if (job.runner_id === runnerId) break; |
| 391 | await sleep(16); |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | runJobs = runJobs.map((job) => { |
| 396 | const { id, started_at: date, run_id: runId, runner_id: runnerId } = job; |
| 397 | return { id, date, runId, runnerId }; |
| 398 | }); |
| 399 | |
| 400 | return runJobs.find((job) => runnerId === job.runnerId); |
| 401 | } |
| 402 | |
| 403 | runnerLogPatterns() { |
| 404 | return { |