Skip to content

Commit 1cbb29a

Browse files
committed
Create option to run dependabot manually
1 parent 658065e commit 1cbb29a

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Manual Dependabot Recreate
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
recreate_dependabot_prs:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
13+
- name: Close Dependabot PRs and delete branches
14+
uses: actions/github-script@v6
15+
with:
16+
github-token: ${{secrets.GITHUB_TOKEN}}
17+
script: |
18+
const prs = await github.rest.pulls.list({
19+
owner: context.repo.owner,
20+
repo: context.repo.repo,
21+
state: 'open'
22+
});
23+
24+
for (const pr of prs.data) {
25+
if (pr.user.login === 'dependabot[bot]') {
26+
// Close the PR
27+
await github.rest.pulls.update({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
pull_number: pr.number,
31+
state: 'closed'
32+
});
33+
34+
// Delete the branch
35+
await github.rest.git.deleteRef({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
ref: 'heads/' + pr.head.ref
39+
});
40+
}
41+
}

0 commit comments

Comments
 (0)