From 4d20c7e5d91a57b210b6276c6381baf9a39494a1 Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Wed, 19 Jul 2023 20:52:04 +0200 Subject: [PATCH] action.yml: add assignees when there is none --- action.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index a41fbbe9..4bb26205 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; @@ -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)}} ${{ 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)}} channel: secops-hotspots color: green verbose: true