Skip to content

Commit

Permalink
Temporary try out via environments instead # 3481
Browse files Browse the repository at this point in the history
- directly writing to the file did not work
- directly using set-output command did not work
- trying environment setting method as alternative
  • Loading branch information
de-jcup committed Dec 13, 2024
1 parent 4ac750f commit 8be74c7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
28 changes: 16 additions & 12 deletions github-actions/scan/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
*/
Expand Down Expand Up @@ -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);
}
Expand All @@ -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 '';
Expand Down Expand Up @@ -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();
Expand Down
21 changes: 14 additions & 7 deletions github-actions/scan/src/output-helper.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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' });
}

0 comments on commit 8be74c7

Please sign in to comment.