mirror of
https://github.com/booklore-app/booklore.git
synced 2025-12-23 22:28:11 -05:00
Automatically delete all remote branches that have been merged into master or develop, excluding the master and develop branches themselves
This commit is contained in:
committed by
Aditya Chandel
parent
51df32415e
commit
bf87f030f8
14
.github/workflows/docker-build-publish.yml
vendored
14
.github/workflows/docker-build-publish.yml
vendored
@@ -128,12 +128,16 @@ jobs:
|
||||
run: |
|
||||
gh release edit ${{ env.new_tag }} --draft=false
|
||||
|
||||
- name: Delete Feature/Bug Branches (Only for Master and Develop)
|
||||
- name: Delete Merged Branches (Only for Master and Develop)
|
||||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop'
|
||||
run: |
|
||||
git fetch --prune
|
||||
for branch in $(git branch -r | grep 'origin/feature/' || grep 'origin/bug/'); do
|
||||
branch_name=${branch#origin/}
|
||||
echo "Deleting branch: $branch_name"
|
||||
git push origin --delete "$branch_name"
|
||||
merged_branches=$(git branch -r --merged origin/master origin/develop | sed 's/ *origin\///')
|
||||
for branch in $merged_branches; do
|
||||
if [[ "$branch" != "master" && "$branch" != "develop" ]]; then
|
||||
echo "Deleting merged branch: $branch"
|
||||
git push origin --delete "$branch"
|
||||
else
|
||||
echo "Skipping protected branch: $branch"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user