@@ -2,46 +2,31 @@ name: Security Vulnerability Slack Notification
22
33# This workflow runs whenever a Dependabot alert is created or reopened.
44on :
5- workflow_dispatch :
6- inputs :
7- vulnerability_summary :
8- description : ' Vulnerability Summary'
9- required : true
10- default : ' Test vulnerability found in package-a'
11- alert_url :
12- description : ' Alert URL'
13- required : true
14- default : ' https://github.com/placeholder/alert/test-123'
15- action_type :
16- description : ' Action Type (created or reopened)'
17- required : true
18- default : ' created'
5+ dependabot_alert :
6+ types : [created, reopened]
197
208jobs :
219 notify_slack_on_alert :
22- # if: github.event.action == 'created' || github.event.action == 'reopened'
2310 runs-on : ubuntu-latest
2411 steps :
2512 - name : Send Slack Notification via Direct Curl Payload
2613 run : |
27- MESSAGE_TEXT="*🧪 Test Dependabot Alert - ${{ github.event.inputs.action_type }} 🧪 *\n\n*Repository :* ${{ github.repository }}\n*Test Summary :* ${{ github.event.inputs.vulnerability_summary }}\n\n*View Details :* ${{ github.event.inputs.alert_url }}\n\n:bell: Notification sent to #docs-devdocs-notifications "
14+ MESSAGE_TEXT="*🚨 Dependabot Alert: ${{ github.event.action }} 🚨 *\n\n*Vulnerability :* ${{ github.event.alert.security_vulnerability.package.ecosystem }} package *${{ github.event.alert.security_vulnerability.package.name }}* \n*Severity :* ${{ github.event.alert.security_vulnerability.severity }}\n*Repository :* ${{ github.repository }}\n\n*View Details:* ${{ github.event.alert.html_url }} "
2815
29- # 2. Construct the full JSON payload
3016 SLACK_PAYLOAD=$(jq -n \
3117 --arg text "${MESSAGE_TEXT}" \
3218 '{
3319 "channel": "#docs-devdocs-notifications",
34- "username": "Dependabot Test Alert ",
35- "icon_emoji": ":dependabot :",
20+ "username": "Dependabot Notifier ",
21+ "icon_emoji": ":lock :",
3622 "text": $text
3723 }')
3824
39- # 3. Send the request directly to the webhook URL
40- # Using 'jq' to properly construct and escape the JSON ensures compatibility.
25+ # 3. Send the request directly to the webhook URL stored as a secret
4126 curl -X POST \
4227 -H 'Content-type: application/json' \
4328 --data "$SLACK_PAYLOAD" \
4429 ${{ secrets.SLACK_WEBHOOK }}
4530 env :
46- # jq is a required tool for this method, but is pre-installed on GitHub runners .
31+ # jq is pre-installed on GitHub runners and is used to safely build the JSON payload .
4732 JQ_VERSION : 1.6
0 commit comments