Skip to content

Commit 8e046bb

Browse files
igor.chelyshkinigor.chelyshkin
authored andcommitted
update
1 parent e8fa6ea commit 8e046bb

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Delete All Merged Branches
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
delete-merged-branches:
8+
runs-on: ubuntu-24.04
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Delete merged branches
16+
run: |
17+
git config --global user.name "github-actions"
18+
git config --global user.email "github-actions@github.com"
19+
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
20+
21+
echo "Fetching all remote branches..."
22+
git fetch --all --prune
23+
24+
echo "Looking for merged branches..."
25+
MERGED_BRANCHES=$(git branch -r --merged origin/main | grep -v 'origin/main' | grep -v 'origin/release/' | sed 's|origin/||')
26+
27+
if [[ -z "$MERGED_BRANCHES" ]]; then
28+
echo "No merged branches found."
29+
exit 0
30+
fi
31+
32+
echo "Merged branches to delete:"
33+
echo "$MERGED_BRANCHES"
34+
35+
for branch in $MERGED_BRANCHES; do
36+
echo "Deleting branch: $branch"
37+
git push origin --delete "$branch"
38+
done

0 commit comments

Comments
 (0)