Skip to content

Commit

Permalink
Create remove-pr-closed-branch.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Carvin-Yu authored Jan 6, 2024
1 parent f860e9e commit 093c84b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/remove-pr-closed-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Delete Branch

on:
pull_request:
types:
- closed

jobs:
delete-branch:
runs-on: ubuntu-latest
steps:
- name: Check if PR is merged
id: pr
uses: actions/github-script@v4
with:
github-token: ${{ secrets.TOKEN_GITHUB }}
script: |
const pr = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
return { merged: pr.data.merged };
- name: Delete branch
if: ${{ steps.pr.outputs.merged == true }}
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
git fetch --prune
git branch -d ${{ github.head_ref }}
git push origin --delete ${{ github.head_ref }}

0 comments on commit 093c84b

Please sign in to comment.