From ebcce8eaa8caca9e869e159661501b928409cfe1 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:15:18 +0530 Subject: [PATCH] Added octokit parser --- src/buildSummary.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/buildSummary.ts b/src/buildSummary.ts index 70b27a4..ea37590 100644 --- a/src/buildSummary.ts +++ b/src/buildSummary.ts @@ -86,15 +86,15 @@ export function getWorkflowStepNames(repository: string) { const [owner, repo] = repository.split('/'); console.log(owner); console.log(repo); - // const runId = process.env.GITHUB_RUN_ID - //console.log(runId); - const path = '.github/workflows/bat.yml'; + const runId = process.env.GITHUB_RUN_ID + console.log(runId); + //const path = '.github/workflows/bat.yml'; console.log(path); - getWorkflowRunJobs(owner as string, repo as string, path as string); + getWorkflowRunJobs(owner as string, repo as string, runId 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,16 +102,18 @@ 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.getWorkflowRun({ owner, repo, - path, + runId, }); // Iterate over the jobs and log the step names - console.log(response); - const jobs = response.data.jobs; + const jobs = response.data; + console.log(response); + const steps = jobs.steps; + console.log(steps); } catch (error) { console.error(error); }