From 6b830fda40d1dd50d33d11e40839ce5e1dfd4d94 Mon Sep 17 00:00:00 2001 From: Taichi Sasaki Date: Tue, 20 Sep 2022 17:29:43 +0900 Subject: [PATCH] Properly handle pagination of job and took --- src/fields.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/fields.ts b/src/fields.ts index 37123889..d8e2ce77 100644 --- a/src/fields.ts +++ b/src/fields.ts @@ -103,14 +103,15 @@ export class FieldFactory { } private async took(): Promise { - const resp = await this.octokit?.rest.actions.listJobsForWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.runId, - }); - const currentJob = resp?.data.jobs.find(job => - this.isCurrentJobName(job.name), + const jobs = await this.octokit?.paginate( + this.octokit?.rest.actions.listJobsForWorkflowRun, + { + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.runId, + }, ); + const currentJob = jobs.find(job => this.isCurrentJobName(job.name)); if (currentJob === undefined) { process.env.AS_TOOK = this.jobIsNotFound; return this.jobIsNotFound; @@ -140,14 +141,15 @@ export class FieldFactory { private async job(): Promise { const { owner } = context.repo; - const resp = await this.octokit?.rest.actions.listJobsForWorkflowRun({ - owner, - repo: context.repo.repo, - run_id: context.runId, - }); - const currentJob = resp?.data.jobs.find(job => - this.isCurrentJobName(job.name), + const jobs = await this.octokit?.paginate( + this.octokit?.rest.actions.listJobsForWorkflowRun, + { + owner, + repo: context.repo.repo, + run_id: context.runId, + }, ); + const currentJob = jobs.find(job => this.isCurrentJobName(job.name)); if (currentJob === undefined) { process.env.AS_JOB = this.jobIsNotFound; return this.jobIsNotFound;