[CI] Merge pr/beta/all into beta #175
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Delete PR branches' | |
on: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
delete_pr_branches: | |
name: 'Delete PR branches' | |
if: startsWith(github.head_ref, 'pr/') | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- name: 'Delete PR head branch' | |
uses: actions/github-script@v7 | |
env: | |
HEAD_REF: ${{ github.head_ref }} | |
with: | |
script: | | |
const { repo, owner } = context.repo; | |
try { | |
await github.rest.git.deleteRef({ | |
owner: owner, | |
repo: repo, | |
ref: `heads/${process.env.HEAD_REF}`, | |
}); | |
} catch (e) { | |
console.warn(e); | |
} | |
- name: 'Delete PR other head branches' | |
if: ${{ endsWith(github.head_ref, '/all') && github.event.pull_request.merged }} | |
uses: actions/github-script@v7 | |
env: | |
BASE_REF: ${{ github.base_ref }} | |
with: | |
script: | | |
const { repo, owner } = context.repo; | |
const pulls = await github.rest.pulls.list({ | |
owner: owner, | |
repo: repo, | |
base: process.env.BASE_REF, | |
state: 'open', | |
}); | |
for (const pr of pulls.data) { | |
try { | |
await github.rest.git.deleteRef({ | |
owner: owner, | |
repo: repo, | |
ref: `heads/${pr.head.ref}`, | |
}); | |
} catch (e) { | |
console.warn(e); | |
} | |
} |