Skip to content

Update README.md

Update README.md #2

name: Delete Unmerged Branch
on:
pull_request:
branches: [15.0]
types: [closed]
jobs:
worker:
if: ${{ github.event.pull_request.merged_at == '' }}
runs-on: ubuntu-latest
steps:
- name: delete-unmerged-branch
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { repo, owner } = context.repo;
const ref = `heads/${context.payload.pull_request.head.ref}`;
const deleteParams = { owner, repo, ref };
console.log(`Deleting branch: "${ref}"`);
try {
github.rest.git.deleteRef(deleteParams);
} catch(e) {
console.log("Cannot delete branch; error:", e);
}