Skip to content

Commit

Permalink
action.yml: add assignees when there is none
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed Jul 20, 2023
1 parent 39c48ca commit 3337365
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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: |
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3337365

Please sign in to comment.