diff --git a/action.cjs b/action.cjs index 3a87accd..cf01ef77 100644 --- a/action.cjs +++ b/action.cjs @@ -5,6 +5,11 @@ function hashFiles (filename) { } module.exports = async ({ github, context, inputs, steps, actionPath, core }) => { + // reviewdog-fail-log-head step + let reviewdogFailLogHead = null + if (steps['reviewdog-enabled-pr'].outputs.result === 'true' && inputs.slack_token && hashFiles('reviewdog.fail.log')) { + reviewdogFailLogHead = '\n' + require('fs').readFileSync('reviewdog.fail.log', 'UTF-8').split('\n').slice(0, 4).join('\n') + } // assignees-slack step let slackAssignees = null if (steps['reviewdog-enabled-pr'].outputs.result === 'true') { @@ -39,7 +44,7 @@ module.exports = async ({ github, context, inputs, steps, actionPath, core }) => await sendSlackMessage({ slack_token: inputs.slack_token, - text: `[security-action] ${actor} action failed, plz take a look. /cc ${slackAssignees} ${steps['reviewdog-fail-log-head'].outputs.result}`, + text: `[security-action] ${actor} action failed, plz take a look. /cc ${slackAssignees} ${reviewdogFailLogHead}`, message, channel: '#secops-hotspots', color: 'red' diff --git a/action.yml b/action.yml index 18190233..de895e9c 100644 --- a/action.yml +++ b/action.yml @@ -298,12 +298,6 @@ runs: uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: script: throw new Error('Error was thrown and Slack token is missing, exiting eagerly!') - - if: ${{ steps.reviewdog-enabled-pr.outputs.result == 'true' && inputs.slack_token && hashFiles('reviewdog.fail.log') }} - id: reviewdog-fail-log-head - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - with: - script: | - return '\n'+require('fs').readFileSync('reviewdog.fail.log', 'UTF-8').split('\n').slice(0, 4).join('\n') - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: script: |