From e8045a4b75a8ffe1af9f47a1422b528f890df6c9 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Mon, 9 Feb 2026 04:50:08 +0300 Subject: [PATCH] fix: bidirectional sync between main and master branches --- .github/workflows/sync-branches.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sync-branches.yml b/.github/workflows/sync-branches.yml index e6f67b9..ffee2f9 100644 --- a/.github/workflows/sync-branches.yml +++ b/.github/workflows/sync-branches.yml @@ -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