From 3f92a94b35d503527ccd55f32c1f99065b8899b4 Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Sat, 8 Jun 2024 01:26:19 +0200 Subject: [PATCH] main action: remove process.env usages --- actions/main/action.cjs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/actions/main/action.cjs b/actions/main/action.cjs index 0ce2f644..7f1687b6 100644 --- a/actions/main/action.cjs +++ b/actions/main/action.cjs @@ -80,11 +80,11 @@ module.exports = async ({ github, context, inputs, actionPath, core, debug = fal debugLog('Security Action enabled') // reviewdog-enabled-pr steps - const reviewdogEnabledPr = options.baseline_scan_only && process.env.GITHUB_EVENT_NAME === 'pull_request' && context.actor !== 'dependabot[bot]' - debugLog(`Security Action enabled for PR: ${reviewdogEnabledPr}, baseline_scan_only: ${options.baseline_scan_only}, GITHUB_EVENT_NAME: ${process.env.GITHUB_EVENT_NAME}, context.actor: ${context.actor}`) + const reviewdogEnabledPr = options.baseline_scan_only && context.eventName === 'pull_request' && context.actor !== 'dependabot[bot]' + debugLog(`Security Action enabled for PR: ${reviewdogEnabledPr}, baseline_scan_only: ${options.baseline_scan_only}, GITHUB_EVENT_NAME: ${context.eventName}, context.actor: ${context.actor}`) // reviewdog-enabled-full steps - const reviewdogEnabledFull = !reviewdogEnabledPr && (!options.baseline_scan_only || process.env.GITHUB_EVENT_NAME === 'workflow_dispatch') - debugLog(`Security Action enabled for full: ${reviewdogEnabledFull}, baseline_scan_only: ${options.baseline_scan_only}, GITHUB_EVENT_NAME: ${process.env.GITHUB_EVENT_NAME}`) + const reviewdogEnabledFull = !reviewdogEnabledPr && (!options.baseline_scan_only || context.eventName === 'workflow_dispatch') + debugLog(`Security Action enabled for full: ${reviewdogEnabledFull}, baseline_scan_only: ${options.baseline_scan_only}, GITHUB_EVENT_NAME: ${context.eventName}`) // reviewdog-enabled steps if (!reviewdogEnabledPr && !reviewdogEnabledFull) { return } debugLog('Security Action enabled for reviewdog') @@ -203,7 +203,9 @@ module.exports = async ({ github, context, inputs, actionPath, core, debug = fal const { default: sendSlackMessage } = await import(`${actionPath}/src/sendSlackMessage.js`) - const message = `Repository: [${process.env.GITHUB_REPOSITORY}](https://github.com/${process.env.GITHUB_REPOSITORY})\npull-request: ${context.payload.pull_request.html_url}\nFindings: ${commentsAfter}` + const repoName = `${context.repo.owner}/${context.repo.repo}` + + const message = `Repository: [${repoName}](https://github.com/${repoName})\npull-request: ${context.payload.pull_request.html_url}\nFindings: ${commentsAfter}` let githubToSlack = {} try {