Skip to content

Commit 69ee882

Browse files
authored
Add workflow to delete merged PR branches (#9)
1 parent f8ed7fc commit 69ee882

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Delete Merged Branch
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
delete-branch:
13+
if: >
14+
github.event.pull_request.merged == true &&
15+
github.event.pull_request.head.repo.full_name == github.repository &&
16+
github.event.pull_request.head.ref != github.event.repository.default_branch &&
17+
github.event.pull_request.head.ref != 'main'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Delete merged branch
21+
run: |
22+
git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" \
23+
--delete "${{ github.event.pull_request.head.ref }}" || true

0 commit comments

Comments
 (0)