Skip to content

Commit 32ae76e

Browse files
committed
ci: add on-close cleanup for merged bot branches
Deletes the head branch when a merged PR was authored by pre-commit-ci[bot] or dependabot[bot]. Runs after the merge completes, so deletion is reliable (the repo-level delete_branch_on_merge setting did not fire for these bot auto-merges). Mirrors tablackburn/SrrDBAutomationToolkit#27.
1 parent 1004e0c commit 32ae76e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Delete merged bot branches
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
delete-branch:
12+
if: >
13+
github.event.pull_request.merged == true &&
14+
(github.event.pull_request.user.login == 'pre-commit-ci[bot]' ||
15+
github.event.pull_request.user.login == 'dependabot[bot]')
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Delete head branch
19+
run: gh api -X DELETE "repos/${GITHUB_REPOSITORY}/git/refs/heads/${HEAD_REF}"
20+
env:
21+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)