feat: add workflow to delete merged branch (#10314)

* Create delete-branch.yml

* Update delete-branch.yml

* Update delete-branch.yml
This commit is contained in:
Pleasure1234 2025-09-24 16:18:22 +08:00 committed by GitHub
parent ec4d106a59
commit 7a3d08672a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

22
.github/workflows/delete-branch.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Delete merged branch
on:
pull_request:
types:
- closed
jobs:
delete-branch:
runs-on: ubuntu-latest
permissions:
contents: write
if: github.event.pull_request.merged == true && github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Delete merged branch
uses: actions/github-script@v7
with:
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${context.payload.pull_request.head.ref}`,
})