Skip to content

Commit

Permalink
action.*: reviewdog-fail-log-head step moved out
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed May 16, 2024
1 parent 282eda4 commit b879370
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 6 additions & 1 deletion action.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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'
Expand Down
6 changes: 0 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down

0 comments on commit b879370

Please sign in to comment.