Skip to content

Manual Merge All Branches into Main #4

Manual Merge All Branches into Main

Manual Merge All Branches into Main #4

Workflow file for this run

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