Bin
2025-12-17 2b99d77d73ba568beff0a549534017caaad8a6de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
name: "Delete PR branch"
 
on:
  pull_request_target:
    types:
      - closed
 
jobs:
  delete-branch:
    if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'fb-')
    runs-on: ubuntu-latest
    steps:
      - uses: hmarr/debug-action@v3.0.0
 
      - name: Delete branch
        uses: actions/github-script@v8
        env:
          HEAD_REF: ${{ github.event.pull_request.head.ref }}
        with:
          github-token: ${{ secrets.GIT_PAT }}
          script: |
            const { repo, owner } = context.repo;
            const head_ref = process.env.HEAD_REF;
            await github.rest.git.deleteRef({
              owner,
              repo,
              ref: `heads/${head_ref}`,
            });
            console.log(`Branch ${head_ref} is deleted`)