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@v8 continue-on-error: true with: script: | github.rest.git.deleteRef({ owner: context.repo.owner, repo: context.repo.repo, ref: `heads/${context.payload.pull_request.head.ref}`, })