Skip to content

Commit 781c83c

Browse files
committed
Add dependabot-issue.yml from gist
1 parent 9576734 commit 781c83c

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Create Issue for Dependabot PRs
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
permissions:
8+
issues: write
9+
pull-requests: read
10+
11+
jobs:
12+
create-tracking-issue:
13+
if: github.actor == 'dependabot[bot]'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Create tracking issue for Dependabot PR
17+
uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const pr = context.payload.pull_request;
21+
const owner = context.repo.owner;
22+
const repo = context.repo.repo;
23+
24+
// Extract version info from PR title
25+
// Typical format: "Bump actions/checkout from 3 to 4"
26+
const title = pr.title;
27+
28+
const issueTitle = `deps: ${title}`;
29+
const issueBody = `## Dependabot Update
30+
31+
${pr.body || 'Automated dependency update.'}
32+
33+
## Pull Request
34+
35+
- PR: #${pr.number}
36+
- Author: @${pr.user.login}
37+
- URL: ${pr.html_url}
38+
39+
---
40+
This issue was automatically created to track the Dependabot update.
41+
`;
42+
43+
const { data: issue } = await github.rest.issues.create({
44+
owner,
45+
repo,
46+
title: issueTitle,
47+
body: issueBody,
48+
labels: ['dependencies', 'github-actions']
49+
});
50+
51+
console.log(`Created tracking issue #${issue.number} for PR #${pr.number}`);
52+
53+
// Update PR body to reference the issue
54+
const updatedBody = `${pr.body || ''}\n\n---\nCloses #${issue.number}`;
55+
56+
await github.rest.pulls.update({
57+
owner,
58+
repo,
59+
pull_number: pr.number,
60+
body: updatedBody
61+
});
62+
63+
console.log(`Updated PR #${pr.number} to close issue #${issue.number}`);

0 commit comments

Comments
 (0)