ci: refactor Gitee sync workflow with selective branch filtering
- Remove hidden workflow file (.sync-to-gitee.yml) and replace with standard naming - Update trigger configuration to sync only main, develop, release/*, and hotfix/* branches - Add tag synchronization for all version tags - Improve branch push logic to explicitly reference origin branches - Simplify workflow by removing unnecessary comments and consolidating sync logic
This commit is contained in:
35
.github/workflows/.sync-to-gitee.yml
vendored
35
.github/workflows/.sync-to-gitee.yml
vendored
@@ -1,35 +0,0 @@
|
|||||||
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 }}/MemoryBear.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
|
|
||||||
36
.github/workflows/sync-to-gitee.yml
vendored
Normal file
36
.github/workflows/sync-to-gitee.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: Sync to Gitee
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main # Production
|
||||||
|
- develop # Integration
|
||||||
|
- 'release/*' # Release preparation
|
||||||
|
- 'hotfix/*' # Urgent fixes
|
||||||
|
tags:
|
||||||
|
- '*' # All version tags (v1.0.0, etc.)
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Source Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Sync to Gitee
|
||||||
|
run: |
|
||||||
|
GITEE_URL="https://${{ secrets.GITEE_USERNAME }}:${{ secrets.GITEE_TOKEN }}@gitee.com/${{ secrets.GITEE_USERNAME }}/MemoryBear.git"
|
||||||
|
git remote add gitee "$GITEE_URL"
|
||||||
|
|
||||||
|
# 遍历并推送所有分支
|
||||||
|
for branch in $(git branch -r | grep -v HEAD | sed 's/origin\///'); do
|
||||||
|
echo "Syncing branch: $branch"
|
||||||
|
git push -f gitee "origin/$branch:refs/heads/$branch"
|
||||||
|
done
|
||||||
|
|
||||||
|
# 推送所有标签
|
||||||
|
echo "Syncing tags..."
|
||||||
|
git push gitee --tags --force
|
||||||
Reference in New Issue
Block a user