From 16a200025a2466e17ce0706b81db654f68a865f9 Mon Sep 17 00:00:00 2001 From: Manuel <112157396+SSFlowtives@users.noreply.github.com> Date: Tue, 10 Dec 2024 19:58:35 +0800 Subject: [PATCH] Update sync-branches.yml --- .github/workflows/sync-branches.yml | 35 +++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/sync-branches.yml b/.github/workflows/sync-branches.yml index a7fbdab..e953342 100644 --- a/.github/workflows/sync-branches.yml +++ b/.github/workflows/sync-branches.yml @@ -2,8 +2,7 @@ name: Sync Branches with Main on: push: - branches: - - main + branches: [main] permissions: contents: write @@ -12,26 +11,38 @@ jobs: sync: runs-on: ubuntu-latest steps: - - name: Checkout repository + - name: Checkout Main Branch uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Set up Git user + - name: Setup Git User run: | git config user.name "GitHub Action" git config user.email "action@github.com" - - name: Sync content branch with main + - name: Sync with Dev Branch run: | - git fetch origin main - git checkout content + git checkout dev + git pull origin dev || echo "No changes to pull for dev" git reset --hard origin/main - git push origin content --force + git merge --squash origin/main || echo "No changes to merge for dev" + if [ -n "$(git status --porcelain)" ]; then + git commit -m "Squash merge changes from main into dev" + git push origin dev || echo "Failed to push dev branch" + fi + git reset --hard main + git push origin dev --force || echo "Failed to force push dev branch" - - name: Sync dev branch with main + - name: Sync with Content Branch run: | - git fetch origin main - git checkout dev + git checkout content + git pull origin content || echo "No changes to pull for content" git reset --hard origin/main - git push origin dev --force + git merge --squash origin/main || echo "No changes to merge for content" + if [ -n "$(git status --porcelain)" ]; then + git commit -m "Squash merge changes from main into content" + git push origin content || echo "Failed to push content branch" + fi + git reset --hard main + git push origin content --force || echo "Failed to force push content branch"