Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

chore: add sync main to dev script (#12202)

Rdmclin235b6d8f9caab
diff --git a/.github/workflows/sync-main-to-dev.yaml b/.github/workflows/sync-main-to-dev.yaml
new file mode 100644
index 00000000000..ee0f9e36ce3
--- /dev/null
+++ b/.github/workflows/sync-main-to-dev.yaml
@@ -0,0 +1,42 @@
+name: 🔄 Branch Synchronization
+
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ sync-branches:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v6
+ with:
+ fetch-depth: 0
+
+ - name: Set up Git
+ run: |
+ git config --global user.name 'GitHub Actions'
+ git config --global user.email '[email protected]'
+
+ - name: Prepare sync branch
+ id: branch
+ run: |
+ echo "SYNC_BRANCH_MAIN_DEV=sync/main-to-dev-$(date +'%Y%m%d')" >> $GITHUB_ENV
+
+ - name: Sync main to dev
+ if: github.ref == 'refs/heads/main'
+ run: |
+ # Sync main to dev
+ git checkout main
+ SYNC_BRANCH_DEV=${{ env.SYNC_BRANCH_MAIN_DEV }}
+ git checkout -B $SYNC_BRANCH_DEV
+ DIFF=$(git diff origin/dev...)
+ if [ -z "$DIFF" ]; then
+ echo "No changes to sync"
+ exit 0
+ fi
+ git push origin $SYNC_BRANCH_DEV -f
+ gh pr create --base dev --head $SYNC_BRANCH_DEV --title "Sync main branch to dev branch" --body "Automatic sync" || exit 0
+ env:
+ GH_TOKEN: ${{ github.token }}