From 5e4c726c098e46229cbf4e2e959d6b3c1e2e4d04 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Wed, 22 May 2024 13:44:21 +0530 Subject: [PATCH] Refactored the JSON strategy --- src/buildSummary.ts | 20 ++++++++++++++++++++ src/index.ts | 5 +---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/buildSummary.ts b/src/buildSummary.ts index 8b29c23..2b9ee9f 100644 --- a/src/buildSummary.ts +++ b/src/buildSummary.ts @@ -53,3 +53,23 @@ export function addBuildSummaryTable(tasks: TaskList): void { .addTable(taskSummaryTableRows) .write(); } + +async function processAndDisplayBuildSummary() { + const runId = process.env.GITHUB_RUN_ID; + + if (!runId) { + console.error('GITHUB_RUN_ID environment variable is not set. Unable to locate the build summary file.'); + return; + } + + try { + const runnerTemp = process.env.RUNNER_TEMP; + console.log("________ "+ runnerTemp); + const filePath = `/tmp/buildSummary_${runId}.json`; + const data = await readJsonFile(filePath); + addBuildSummaryTable(data); + } catch (error) { + console.error('An error occurred while reading the build summary file or adding the build summary table:', error); + } +} + diff --git a/src/index.ts b/src/index.ts index 5d3c3df..3b0f951 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,10 +35,7 @@ async function run() { (cmd,args)=>exec.exec(cmd,args,execOptions), startupOptions ); - const runId = process.env.GITHUB_RUN_ID; - const data = await buildSummary.readJsonFile("/tmp/buildSummary_" + runId + ".json"); - buildSummary.addBuildSummaryTable(data); - + buildSummary.processAndDisplayBuildSummary(); } run().catch((e) => {