Manual Merge All Branches into Main #4
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: Manual Merge All Branches into Main | |
on: | |
workflow_dispatch: | |
jobs: | |
merge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Fetch all branches | |
run: | | |
git fetch --all | |
- name: List all branches | |
id: list_branches | |
run: | | |
BRANCHES=$(git branch -r | grep -v '\->' | grep -v 'origin/main' | sed 's/origin\///' | tr '\n' ' ') | |
echo "BRANCHES=$BRANCHES" >> $GITHUB_ENV | |
shell: bash | |
- name: Merge branches into main | |
run: | | |
git checkout main | |
git pull origin main | |
for branch in ${{ env.BRANCHES }}; do | |
echo "Merging branch $branch into main" | |
git merge --allow-unrelated-histories origin/$branch || exit 1 | |
done | |
git push origin main | |
shell: bash |