ci: add GitHub Actions workflow to sync branches to Gitee

- Add new GitHub Actions workflow file for syncing all branches to Gitee repository
- Configure workflow to trigger on push events to any branch
- Implement branch synchronization logic using git remote and force push
- Add .claude to .gitignore to exclude IDE-specific files
- Enable automated repository mirroring between GitHub and Gitee platforms
This commit is contained in:
Ke Sun
2026-04-02 10:43:06 +08:00
parent fff5e0e8b8
commit f61f86f8fe
2 changed files with 36 additions and 0 deletions

35
.github/workflow/.sync-to-gitee.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Sync All Branches to Gitee
on:
push:
branches:
- '*'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync All Branches
run: |
# 1. 配置 Git 用户信息
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
# 2. 构建带 Token 的 HTTPS 远程地址
GITEE_URL="https://${{ secrets.GITEE_USERNAME }}:${{ secrets.GITEE_TOKEN }}@gitee.com/${{ secrets.GITEE_USERNAME }}/test-push-gitee.git"
# 3. 添加远程仓库 (命名为 gitee)
git remote add gitee $GITEE_URL
# 4. 遍历并推送所有分支
# 这一步会获取本地所有分支名,并依次推送到 Gitee
for branch in $(git branch -r | grep -v HEAD | sed 's/origin\///'); do
echo "Syncing branch: $branch"
git push -f gitee $branch:$branch
done

1
.gitignore vendored
View File

@@ -18,6 +18,7 @@ examples/
.kiro
.vscode
.idea
.claude
# Temporary outputs
.DS_Store