From 8be74c7a476f39c275b289937c605856b8d5109d Mon Sep 17 00:00:00 2001 From: Albert Tregnaghi Date: Fri, 13 Dec 2024 14:49:47 +0100 Subject: [PATCH] Temporary try out via environments instead # 3481 - directly writing to the file did not work - directly using set-output command did not work - trying environment setting method as alternative --- github-actions/scan/dist/index.js | 28 ++++++++++++++---------- github-actions/scan/src/output-helper.ts | 21 ++++++++++++------ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/github-actions/scan/dist/index.js b/github-actions/scan/dist/index.js index aaf960bca..2a7c3d9a6 100644 --- a/github-actions/scan/dist/index.js +++ b/github-actions/scan/dist/index.js @@ -28429,10 +28429,12 @@ function getFieldFromJson(field, jsonData) { return currentKey; } -;// CONCATENATED MODULE: ./src/github-output.ts +// EXTERNAL MODULE: ./node_modules/@actions/core/lib/command.js +var command = __nccwpck_require__(7351); +;// CONCATENATED MODULE: ./src/output-helper.ts // SPDX-License-Identifier: MIT -const NEW_LINE_SEPARATOR = '\n'; +//import * as fs from 'fs'; /** * Sets the value of an output variable for the GitHub Action. * This method is a replacement of usage of core.setOutput(..) method. @@ -28442,12 +28444,14 @@ const NEW_LINE_SEPARATOR = '\n'; * */ function storeOutput(field, value) { - const filePath = process.env['GITHUB_OUTPUT'] || ''; - if (filePath) { - } - else { - core.setOutput(field, value); - } + // const outputFilePath = process.env['GITHUB_OUTPUT'] || ''; + // if (!outputFilePath) { + // throw new Error('GITHUB_OUTPUT environment variable is not set'); + // } + // const outputLine = `${field}=${value}\n`; + // fs.appendFileSync(outputFilePath, outputLine, { encoding: 'utf8' }); + //issueCommand('set-output', { name: `${field}` }, toCommandValue(value)); + (0,command.issueCommand)('set-env', { name: field }, value); } ;// CONCATENATED MODULE: ./src/post-scan.ts @@ -28462,7 +28466,7 @@ function storeOutput(field, value) { -const post_scan_NEW_LINE_SEPARATOR = '\n'; +const NEW_LINE_SEPARATOR = '\n'; /** * Collect all necessary report data, downloads additional report formats (e.g. 'html') if necessary */ @@ -28536,7 +28540,7 @@ async function uploadArtifact(context, name, files) { if (core.isDebug()) { const filesInWorkspace = (0,external_child_process_.execFileSync)('ls', [rootDirectory], { encoding: 'utf-8' - }).split(post_scan_NEW_LINE_SEPARATOR); + }).split(NEW_LINE_SEPARATOR); for (const fileName of filesInWorkspace) { core.debug(fileName); } @@ -28559,7 +28563,7 @@ function resolveReportNameForScanJob(context) { const workspaceDir = sanitize(getWorkspaceDir()); const filesInWorkspace = (0,external_child_process_.execFileSync)('ls', [workspaceDir], { encoding: 'utf-8' - }).split(post_scan_NEW_LINE_SEPARATOR); + }).split(NEW_LINE_SEPARATOR); if (!context.jobUUID) { core.error('Illegal state: No job uuid resolved - not allowed at this point'); return ''; @@ -46215,7 +46219,7 @@ async function postScan(context) { main().catch(handleError); async function main() { - // Seperated launcher and main method. + // Separated launcher and main method. // Reason: launch mechanism would be loaded on imports // before we can handle mocking in integration tests! await launch(); diff --git a/github-actions/scan/src/output-helper.ts b/github-actions/scan/src/output-helper.ts index d3ef3dcc7..2036bf151 100644 --- a/github-actions/scan/src/output-helper.ts +++ b/github-actions/scan/src/output-helper.ts @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT +import { issueCommand } from '@actions/core/lib/command'; +import { toCommandValue} from '@actions/core/lib/utils'; -import * as fs from 'fs'; +//import * as fs from 'fs'; /** * Sets the value of an output variable for the GitHub Action. @@ -11,13 +13,18 @@ import * as fs from 'fs'; * */ export function storeOutput(field: string, value: string) { - const outputFilePath = process.env['GITHUB_OUTPUT'] || ''; + // const outputFilePath = process.env['GITHUB_OUTPUT'] || ''; - if (!outputFilePath) { - throw new Error('GITHUB_OUTPUT environment variable is not set'); - } + // if (!outputFilePath) { + // throw new Error('GITHUB_OUTPUT environment variable is not set'); + // } + + // const outputLine = `${field}=${value}\n`; + + // fs.appendFileSync(outputFilePath, outputLine, { encoding: 'utf8' }); + + //issueCommand('set-output', { name: `${field}` }, toCommandValue(value)); + issueCommand('set-env', { name: field }, value); - const outputLine = `${field}=${value}\n`; - fs.appendFileSync(outputFilePath, outputLine, { encoding: 'utf8' }); }