Skip to content

Commit 334ca2a

Browse files
[CodeQL] Moved notification on failure to a separate step (#218394)
## Summary Moved notification on failure to a separate step.
1 parent fc686f8 commit 334ca2a

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

.github/workflows/codeql.yml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ jobs:
6060
category: "/language:${{matrix.language}}"
6161
ref: ${{ env.CHECKOUT_REF }}
6262
sha: ${{ env.CHECKOUT_SHA }}
63-
- name: Notify to slack on failure
64-
if: ${{ failure() }}
65-
uses: slackapi/[email protected]
66-
with:
67-
method: chat.postMessage
68-
token: ${{ secrets.CODE_SCANNING_SLACK_TOKEN }}
69-
payload: |
70-
channel: ${{ secrets.CODE_SCANNING_SLACK_CHANNEL_ID }}
71-
text: ":broken_heart: CodeQL analysis failed for ${{ github.repository }} on ${{ env.CHECKOUT_SHA }}."
7263
alert:
7364
name: Alert
7465
runs-on: ubuntu-latest
@@ -94,3 +85,39 @@ jobs:
9485
run: |
9586
npm ci --omit=dev
9687
node codeql-alert
88+
notify_on_failure:
89+
name: Failure notification
90+
runs-on: ubuntu-latest
91+
needs: analyze
92+
if: failure()
93+
steps:
94+
- name: Send notification to slack
95+
uses: slackapi/[email protected]
96+
with:
97+
method: chat.postMessage
98+
token: ${{ secrets.CODE_SCANNING_SLACK_TOKEN }}
99+
payload: |
100+
channel: ${{ secrets.CODE_SCANNING_SLACK_CHANNEL_ID }}
101+
"blocks": [
102+
{
103+
"type": "section",
104+
"text": {
105+
"type": "mrkdwn",
106+
"text": ":broken_heart: CodeQL analysis failed for ${{ github.repository }}."
107+
}
108+
},
109+
{
110+
"type": "actions",
111+
"elements": [
112+
{
113+
"type": "button",
114+
"text": {
115+
"type": "plain_text",
116+
"text": "View Workflow Run"
117+
},
118+
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
119+
}
120+
]
121+
}
122+
]
123+

0 commit comments

Comments
 (0)