Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 9818cf5

Browse files
committed
Add GitHub Actions workflow to create issues for high/critical Dependabot alerts
1 parent 6b43c70 commit 9818cf5

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Dependabot high/critical alert issues
2+
3+
on:
4+
dependabot_alert:
5+
types: [created]
6+
7+
permissions:
8+
issues: write
9+
security-events: read
10+
contents: read
11+
12+
jobs:
13+
create_issue_for_high_critical:
14+
runs-on: ubuntu-latest
15+
if: |
16+
github.event.alert.severity == 'high' ||
17+
github.event.alert.severity == 'critical'
18+
19+
steps:
20+
- name: Create tracking issue for alert
21+
uses: actions/github-script@v7
22+
with:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
script: |
25+
const { owner, repo } = context.repo;
26+
const alert = context.payload.alert;
27+
28+
const severity = (alert.severity || 'unknown').toUpperCase();
29+
const pkg = alert.affected_package_name ||
30+
(alert.package && alert.package.name) ||
31+
'unknown-package';
32+
const ghsa = alert.ghsa_id ||
33+
alert.external_identifier ||
34+
'unknown-GHSA';
35+
const alertUrl = alert.html_url ||
36+
alert.url ||
37+
'(no URL provided)';
38+
39+
const teamMention = '@Dopeamin';
40+
41+
const title = `[Dependabot] ${severity} vulnerability in ${pkg} (${ghsa})`;
42+
43+
// Avoid duplicates: search by GHSA id in title
44+
const search = await github.rest.search.issuesAndPullRequests({
45+
q: `repo:${owner}/${repo} "${ghsa}" in:title is:issue`,
46+
});
47+
48+
if (search.data.total_count > 0) {
49+
console.log('Issue already exists for this alert, skipping.');
50+
return;
51+
}
52+
53+
const body = `${teamMention}
54+
55+
A new **${severity}** Dependabot alert was detected.
56+
57+
- **Package**: \`${pkg}\`
58+
- **Advisory (GHSA)**: \`${ghsa}\`
59+
- **Alert URL**: ${alertUrl}
60+
61+
This issue was created automatically by a GitHub Actions workflow.`;
62+
63+
await github.rest.issues.create({
64+
owner,
65+
repo,
66+
title,
67+
body,
68+
labels: ['security', 'dependabot', severity.toLowerCase()],
69+
70+
assignees: ['Dopeamin'],
71+
});

0 commit comments

Comments
 (0)