Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar committed Apr 8, 2024
1 parent 7116e6f commit 14865b3
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions .github/workflows/status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,33 @@ jobs:
} = contentJSON;
// Fetch the first job ID from the workflow run
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: process.env.WORKFLOW_RUN_ID,
});
async function fetchAllJobs(owner, repo, run_id) {
let allJobs = [];
let page = 1;
const perPage = 100; // Adjust this value as needed, up to a maximum of 100
while (true) {
const response = await github.rest.actions.listJobsForWorkflowRun({
owner: owner,
repo: repo,
run_id: run_id,
per_page: perPage,
page: page
});
allJobs = allJobs.concat(response.data.jobs);
if (response.data.jobs.length < perPage) {
break; // No more jobs to fetch, exit the loop
}
page++; // Increment the page number to fetch the next set of jobs
}
return allJobs;
}
const jobs = await fetchAllJobs(context.repo.owner, context.repo.repo, process.env.WORKFLOW_RUN_ID);
console.log(JSON.stringify(jobs.data.jobs, undefined, 2));
const job = jobs.data.jobs.find(job => job.name === JOB_NAME);
const JOB_ID = job ? job.id : null;
Expand Down

0 comments on commit 14865b3

Please sign in to comment.