File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments