Compare commits
4 Commits
multi-repo
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36aa47fc3d | ||
|
|
17ab86648a | ||
| 66511432ed | |||
| 6161f2875d |
84
.gitea/workflows/aliyun_to_gitea_pipeline.yml
Normal file
84
.gitea/workflows/aliyun_to_gitea_pipeline.yml
Normal file
@@ -0,0 +1,84 @@
|
||||
name: 多仓库同步流水线
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'bladex_to_gitea.yaml'
|
||||
- '.gitea/workflows/bladex_to_gitea_pipeline.yml'
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# 每周凌晨1点执行
|
||||
- cron: '0 1 * * 0'
|
||||
|
||||
env:
|
||||
CONFIG_FILE: 'bladex_to_gitea.yaml'
|
||||
|
||||
jobs:
|
||||
sync-repositories:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 签出配置仓库
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: 配置 Git
|
||||
run: |
|
||||
git config --global user.name "gitea-runner"
|
||||
git config --global user.email "actions@gitea.fjy8018.top"
|
||||
git config --global init.defaultBranch master
|
||||
|
||||
- name: 安装依赖
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y python3-yaml jq
|
||||
|
||||
- name: 验证配置文件
|
||||
run: |
|
||||
if [ ! -f "${{ env.CONFIG_FILE }}" ]; then
|
||||
echo "错误: 配置文件 ${{ env.CONFIG_FILE }} 不存在!"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ 配置文件已找到"
|
||||
|
||||
- name: 网络连通性诊断
|
||||
run: |
|
||||
echo "================================================================================"
|
||||
echo "网络连通性诊断"
|
||||
echo "================================================================================"
|
||||
echo ""
|
||||
echo "[1] 检查DNS解析 (center.javablade.com):"
|
||||
if command -v nslookup >/dev/null 2>&1; then
|
||||
nslookup center.javablade.com || echo "❌ nslookup 失败"
|
||||
elif command -v dig >/dev/null 2>&1; then
|
||||
dig center.javablade.com || echo "❌ dig 失败"
|
||||
else
|
||||
getent hosts center.javablade.com || echo "❌ DNS 解析失败"
|
||||
fi
|
||||
echo ""
|
||||
echo "[2] 检查网络连通性:"
|
||||
if command -v ping >/dev/null 2>&1; then
|
||||
ping -c 3 -W 5 center.javablade.com || echo "❌ ping 失败"
|
||||
else
|
||||
echo "⚠️ ping 命令不可用,跳过连通性测试"
|
||||
fi
|
||||
echo ""
|
||||
echo "[3] 检查是否可以访问上游仓库(匿名测试):"
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
timeout 30 git ls-remote https://center.javablade.com/blade/BladeX-Tool.git HEAD || echo "❌ 无法访问仓库"
|
||||
else
|
||||
echo "⚠️ git 命令不可用"
|
||||
fi
|
||||
echo ""
|
||||
echo "================================================================================"
|
||||
|
||||
- name: 从配置文件中提取仓库并同步
|
||||
env:
|
||||
UPSTREAM_USERNAME: ${{ secrets.ALIYUN_UPSTREAM_USERNAME }}
|
||||
UPSTREAM_TOKEN: ${{ secrets.ALIYUN_UPSTREAM_TOKEN }}
|
||||
TARGET_USERNAME: ${{ secrets.TARGET_USERNAME }}
|
||||
TARGET_TOKEN: ${{ secrets.TARGET_TOKEN }}
|
||||
run: python3 sync_repos.py
|
||||
@@ -5,15 +5,15 @@ on:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'repos.yaml'
|
||||
- '.gitea/workflows/*.yml'
|
||||
- 'bladex_to_gitea.yaml'
|
||||
- '.gitea/workflows/bladex_to_gitea_pipeline.yml'
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# 每天凌晨1点执行
|
||||
- cron: '0 1 * * *'
|
||||
# 每周凌晨1点执行
|
||||
- cron: '0 1 * * 0'
|
||||
|
||||
env:
|
||||
CONFIG_FILE: 'repos.yaml'
|
||||
CONFIG_FILE: 'bladex_to_gitea.yaml'
|
||||
|
||||
jobs:
|
||||
sync-repositories:
|
||||
35
aliyun_to_gitea.yaml
Normal file
35
aliyun_to_gitea.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
# 多仓库同步配置文件
|
||||
# 定义需要同步的仓库对,源仓库 -> 目标仓库
|
||||
repositories:
|
||||
- name: "bladex-tool"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Tool.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Tool.git"
|
||||
branch: "master"
|
||||
- name: "BladeX-Safety"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Safety.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Safety.git"
|
||||
branch: "master"
|
||||
- name: "bladex"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX.git"
|
||||
branch: "master"
|
||||
- name: "BladeX-Doc"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Doc.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Doc.git"
|
||||
branch: "master"
|
||||
- name: "BladeX-Boot"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Boot.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Boot.git"
|
||||
branch: "master"
|
||||
- name: "Saber"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/Saber.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/Saber.git"
|
||||
branch: "master"
|
||||
- name: "BladeX-Biz"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Biz.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Biz.git"
|
||||
branch: "master"
|
||||
- name: "Saber3"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/Saber3.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/Saber3.git"
|
||||
branch: "master"
|
||||
35
bladex_to_gitea.yaml
Normal file
35
bladex_to_gitea.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
# 多仓库同步配置文件
|
||||
# 定义需要同步的仓库对,源仓库 -> 目标仓库
|
||||
repositories:
|
||||
- name: "bladex-tool"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Tool.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Tool.git"
|
||||
branch: "master"
|
||||
- name: "BladeX-Safety"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Safety.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Safety.git"
|
||||
branch: "master"
|
||||
- name: "bladex"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX.git"
|
||||
branch: "master"
|
||||
- name: "BladeX-Doc"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Doc.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Doc.git"
|
||||
branch: "master"
|
||||
- name: "BladeX-Boot"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Boot.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Boot.git"
|
||||
branch: "master"
|
||||
- name: "Saber"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/Saber.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/Saber.git"
|
||||
branch: "master"
|
||||
- name: "BladeX-Biz"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Biz.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Biz.git"
|
||||
branch: "master"
|
||||
- name: "Saber3"
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/Saber3.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/Saber3.git"
|
||||
branch: "master"
|
||||
16
repos.yaml
16
repos.yaml
@@ -1,16 +0,0 @@
|
||||
# 多仓库同步配置文件
|
||||
# 定义需要同步的仓库对,源仓库 -> 目标仓库
|
||||
repositories:
|
||||
# 示例:同步 BladeX-Tool 仓库
|
||||
- name: "bladex-tool" # 仓库名称(用于日志输出)
|
||||
source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@center.javablade.com/blade/BladeX-Tool.git"
|
||||
target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/BladeX/BladeX-Tool.git"
|
||||
branch: "master" # 要同步的分支
|
||||
|
||||
# 示例:同步另一个仓库(取消注释并修改以下配置)
|
||||
# - name: "another-repo"
|
||||
# source_url: "https://${UPSTREAM_USERNAME}:${UPSTREAM_TOKEN}@github.com/example/repo.git"
|
||||
# target_url: "https://${TARGET_USERNAME}:${TARGET_TOKEN}@gitea.fjy8018.top/home/repo.git"
|
||||
# branch: "main"
|
||||
|
||||
# 添加更多仓库同步配置...
|
||||
@@ -88,7 +88,7 @@ def sync_repository(repo_config):
|
||||
print(f"\n[1/6] 克隆目标仓库...")
|
||||
result = subprocess.run(
|
||||
['git', 'clone', target_url, work_dir],
|
||||
capture_output=True, text=True, timeout=300
|
||||
capture_output=True, text=True, timeout=3600
|
||||
)
|
||||
if result.returncode != 0:
|
||||
print(f"❌ 克隆目标仓库失败:")
|
||||
@@ -112,7 +112,7 @@ def sync_repository(repo_config):
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['git', 'fetch', 'upstream'],
|
||||
capture_output=True, text=True, timeout=200
|
||||
capture_output=True, text=True, timeout=3600
|
||||
)
|
||||
if result.returncode == 0:
|
||||
break
|
||||
@@ -166,7 +166,7 @@ def sync_repository(repo_config):
|
||||
print(f"[6/6] 推送到目标仓库...")
|
||||
result = subprocess.run(
|
||||
['git', 'push', '--force', '--tags', 'origin', f'refs/heads/{branch}'],
|
||||
capture_output=True, text=True, timeout=600
|
||||
capture_output=True, text=True, timeout=3600
|
||||
)
|
||||
if result.returncode != 0:
|
||||
print(f"❌ 推送到目标仓库失败:")
|
||||
|
||||
Reference in New Issue
Block a user