fix: bidirectional sync between main and master branches

This commit is contained in:
2026-02-09 04:50:08 +03:00
parent 71d14b884a
commit e8045a4b75
+22 -5
View File
@@ -1,8 +1,9 @@
name: Sync master to main
name: Sync main and master branches
on:
push:
branches:
- main
- master
jobs:
@@ -13,11 +14,27 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Sync master to main
- name: Setup Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout main
git merge master --no-edit
git push origin main
- name: Sync branches
run: |
# Get the branch that was pushed to
PUSHED_BRANCH="${GITHUB_REF#refs/heads/}"
if [ "$PUSHED_BRANCH" = "main" ]; then
TARGET_BRANCH="master"
else
TARGET_BRANCH="main"
fi
echo "Syncing $PUSHED_BRANCH → $TARGET_BRANCH"
git fetch origin $TARGET_BRANCH || git checkout -b $TARGET_BRANCH
git checkout $TARGET_BRANCH
git merge origin/$PUSHED_BRANCH --no-edit -m "Sync from $PUSHED_BRANCH"
git push origin $TARGET_BRANCH