File tree 2 files changed +64
-28
lines changed
2 files changed +64
-28
lines changed Original file line number Diff line number Diff line change 31
31
security-events : write # for github/codeql-action/upload-sarif to upload SARIF results
32
32
actions : read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
33
33
runs-on : ubuntu-latest
34
- environment : prod
34
+ outputs :
35
+ CVE_CRITICAL : ${{env.CVE_CRITICAL}}
36
+ CVE_HIGH : ${{env.CVE_HIGH}}
37
+ CVE_MEDIUM : ${{env.CVE_MEDIUM}}
35
38
steps :
36
39
- name : Checkout the code
37
40
uses : actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
@@ -60,30 +63,13 @@ jobs:
60
63
id : cve-threshold
61
64
if : env.CVE_HIGH > 0 || env.CVE_CRITICAL > 0
62
65
run : exit 1
63
- - name : Send notification to Slack
64
- id : slack
65
- if : always() && github.event_name == 'schedule' && steps.cve-threshold.outcome == 'failure'
66
- uses : slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
67
- with :
68
- payload : |
69
- {
70
- "blocks": [
71
- {
72
- "type": "header",
73
- "text": {
74
- "type": "plain_text",
75
- "text": "[ ${{ github.event.repository.name }} ]"
76
- }
77
- },
78
- {
79
- "type": "section",
80
- "text": {
81
- "type": "mrkdwn",
82
- "text": " `CRITICAL` : *${{ env.CVE_CRITICAL }}*\n\n`HIGH` : *${{ env.CVE_HIGH }}*\n\n`MEDIUM` : *${{ env.CVE_MEDIUM }}*\n\n<https://github.com/${{ github.repository }}/security/code-scanning |See details on GitHub>"
83
- }
84
- }
85
- ]
86
- }
87
- env :
88
- SLACK_WEBHOOK_URL : ${{ secrets.CVE_SCAN_SLACK_WEBHOOK }}
89
- SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
66
+
67
+ SendSlackNotification :
68
+ needs : BuildAndScan
69
+ uses : ./.github/workflows/send-notification.yml
70
+ if : github.event_name == 'schedule' && needs.BuildAndScan.steps.cve-threshold.outcome == 'failure'
71
+ with :
72
+ CVE_CRITICAL : ${{needs.BuildAndScan.outputs.CVE_CRITICAL}}
73
+ CVE_HIGH : ${{needs.BuildAndScan.outputs.CVE_HIGH}}
74
+ CVE_MEDIUM : ${{needs.BuildAndScan.outputs.CVE_MEDIUM}}
75
+ secrets : inherit
Original file line number Diff line number Diff line change
1
+ name : " Send notification"
2
+
3
+ on :
4
+ workflow_call :
5
+ inputs :
6
+ CVE_CRITICAL :
7
+ required : true
8
+ type : string
9
+ CVE_HIGH :
10
+ required : true
11
+ type : string
12
+ CVE_MEDIUM :
13
+ required : true
14
+ type : string
15
+ secrets :
16
+ CVE_SCAN_SLACK_WEBHOOK :
17
+ required : true
18
+
19
+ jobs :
20
+ Notify :
21
+ name : Notify Slack
22
+ runs-on : ubuntu-latest
23
+ environment : prod
24
+ steps :
25
+ - name : Send notification to Slack
26
+ id : slack
27
+ uses : slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
28
+ with :
29
+ payload : |
30
+ {
31
+ "blocks": [
32
+ {
33
+ "type": "header",
34
+ "text": {
35
+ "type": "plain_text",
36
+ "text": "[ ${{ github.event.repository.name }} ]"
37
+ }
38
+ },
39
+ {
40
+ "type": "section",
41
+ "text": {
42
+ "type": "mrkdwn",
43
+ "text": " `CRITICAL` : *${{ inputs.CVE_CRITICAL }}*\n\n`HIGH` : *${{ inputs.CVE_HIGH }}*\n\n`MEDIUM` : *${{ inputs.CVE_MEDIUM }}*\n\n<https://github.com/${{ github.repository }}/security/code-scanning |See details on GitHub>"
44
+ }
45
+ }
46
+ ]
47
+ }
48
+ env :
49
+ SLACK_WEBHOOK_URL : ${{ secrets.CVE_SCAN_SLACK_WEBHOOK }}
50
+ SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
You can’t perform that action at this time.
0 commit comments