komikku/.github/workflows/delete_merged_branch.yml
renovate[bot] 750d7f4022
chore(deps): pin actions/checkout action to f43a0e5 (#283)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-26 00:08:38 +07:00

25 lines
764 B
YAML

name: Delete Merged Branch
on:
pull_request:
types: [closed]
jobs:
delete_merged_branch:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Delete branch
run: |
branch_name=$(echo "${{ github.event.pull_request.head.ref }}")
if [ "$branch" != "refs/heads/main" ] && [ "$branch" != "refs/heads/master" ]; then
echo "Deleting branch ${branch_name}"
git push origin --delete $branch_name
else
echo "Skipping deletion of main or master branch"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}