From 552060a466d1b2e70ed6cb0065e4f579057c6cf8 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:56:43 +0530 Subject: [PATCH] Added octokit parser --- src/buildSummary.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/buildSummary.ts b/src/buildSummary.ts index 06de7f3..c137559 100644 --- a/src/buildSummary.ts +++ b/src/buildSummary.ts @@ -88,13 +88,13 @@ export function getWorkflowStepNames(repository: string) { console.log(repo); const runId = process.env.GITHUB_RUN_ID console.log(runId); - const path = '.github/workflows/bat.yml'; - console.log(path); + //const path = '.github/workflows/bat.yml'; + //console.log(path); getWorkflowRunJobs(owner as string, repo as string, path as string); } -export async function getWorkflowRunJobs(owner: string, repo: string, path: string) { +export async function getWorkflowRunJobs(owner: string, repo: string, runID: string) { // Replace with your GitHub personal access token const octokit = new Octokit({ @@ -102,17 +102,17 @@ export async function getWorkflowRunJobs(owner: string, repo: string, path: stri }); try { // Fetch the jobs for the specified workflow run - const response = await octokit.repos.getContent({ + const response = await octokit.actions.listJobsForWorkflowRun({ owner, repo, - path, + runID, }); - const contentEncoded = response.data.content; - const contentDecoded = Buffer.from(contentEncoded, 'base64').toString('utf-8'); + const contentEncoded = response.data.jobs; + //const contentDecoded = Buffer.from(contentEncoded, 'base64').toString('utf-8'); // Iterate over the jobs and log the step names console.log(contentDecoded); - const jobs = response.data.jobs; + } catch (error) { console.error(error);