We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 71e0e0f + 935b822 commit 0c3e491Copy full SHA for 0c3e491
1 file changed
.github/workflows/delete-merged-branch.yml
@@ -0,0 +1,23 @@
1
+name: Delete merged branch
2
+
3
+on:
4
+ pull_request:
5
+ types:
6
+ - closed
7
8
+jobs:
9
+ delete-branch:
10
+ if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Delete merged branch
14
+ run: |
15
+ branch="${{ github.event.pull_request.head.ref }}"
16
+ repo="${{ github.repository }}"
17
+ token="${{ secrets.GITHUB_TOKEN }}"
18
+ if [[ "$branch" != "main" && "$branch" != "master" ]]; then
19
+ curl -s -X DELETE \
20
+ -H "Authorization: Bearer $token" \
21
+ -H "Accept: application/vnd.github+json" \
22
+ "https://api.github.com/repos/$repo/git/refs/heads/$branch"
23
+ fi
0 commit comments