diff --git a/action.yml b/action.yml index a41fbbe9..c7ba47d9 100644 --- a/action.yml +++ b/action.yml @@ -300,6 +300,8 @@ runs: - id: assignees-after if: ${{ steps.reviewdog-enabled-pr.outputs.result == 'true' }} uses: actions/github-script@v6 + env: + ASSIGNEES: ${{ inputs.assignees }} with: script: | var query = `query($owner:String!, $name:String!, $prnumber:Int!) { @@ -341,13 +343,17 @@ runs: ).flat())] console.log("assignees: %o", assignees); - return assignees.join('\n'); + if (assignees.length > 0) { + return assignees.join(' '); + } else { + return process.env.ASSIGNEES.split(/\s+/).filter((str) => str !== '').join(' '); + } - id: assignee-removed-label if: ${{ steps.reviewdog-enabled-pr.outputs.result == 'true' }} uses: actions/github-script@v6 env: - ASSIGNEES: ${{ steps.assignees-after.outputs.result && fromJson(steps.assignees-after.outputs.result) }} + ASSIGNEES: ${{ fromJson(steps.assignees-after.outputs.result) }} with: script: | const { ASSIGNEES } = process.env; @@ -436,7 +442,7 @@ runs: if: ${{ steps.reviewdog-enabled-pr.outputs.result == 'true' && steps.should-trigger.outputs.result == 'true' }} with: github_token: ${{ inputs.github_token }} - assignees: ${{ fromJson(steps.assignees-after.outputs.result) }} + assignees: ${{ fromJson(steps.assignees-after.outputs.result.split(/\s+/).join("\n")) }} - if: ${{ steps.reviewdog-enabled-pr.outputs.result == 'true' && hashFiles('reviewdog.fail.log') }} shell: bash run: | @@ -458,7 +464,7 @@ runs: with: slack_token: ${{ inputs.slack_token }} message: | - [semgrep] @${{ github.actor }} action failed, plz take a look. /cc ${{steps.assignees.outputs.result}} ${{ fromJson(steps.reviewdog-fail-log-head.outputs.result) }} + [semgrep] @${{ github.actor }} action failed, plz take a look. /cc ${{fromJson(steps.assignees-after.outputs.result).split(/\s+/).map(s=>"@"+s).join(" ")}} ${{ fromJson(steps.reviewdog-fail-log-head.outputs.result) }} channel: secops-hotspots color: red verbose: true @@ -467,7 +473,7 @@ runs: with: slack_token: ${{ inputs.slack_token }} message: | - [semgrep] @${{ github.actor }} pushed commits. /cc ${{steps.assignees.outputs.result}} + [semgrep] @${{ github.actor }} pushed commits. /cc ${{fromJson(steps.assignees-after.outputs.result).split(/\s+/).map(s=>"@"+s).join(" ")}} channel: secops-hotspots color: green verbose: true