name: Delete backport branch on: pull_request: types: [closed] permissions: contents: write jobs: delete-backport-branch: if: > github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'backport/') runs-on: ubuntu-latest steps: - name: Delete backport branch uses: actions/github-script@v9 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const ref = context.payload.pull_request.head.ref; await github.rest.git.deleteRef({ owner: context.repo.owner, repo: context.repo.repo, ref: `heads/${ref}` });