Files
code-sync-project/.gitea/workflows/multi-repo-sync.yml
2025-11-20 21:52:51 +08:00

54 lines
1.3 KiB
YAML

name: 多仓库同步流水线
on:
push:
branches:
- master
paths:
- 'repos.yaml'
- '.gitea/workflows/*.yml'
workflow_dispatch:
schedule:
# 每天凌晨1点执行
- cron: '0 1 * * *'
env:
CONFIG_FILE: 'repos.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: 从配置文件中提取仓库并同步
env:
UPSTREAM_USERNAME: ${{ secrets.UPSTREAM_USERNAME }}
UPSTREAM_TOKEN: ${{ secrets.UPSTREAM_TOKEN }}
TARGET_USERNAME: ${{ secrets.TARGET_USERNAME }}
TARGET_TOKEN: ${{ secrets.TARGET_TOKEN }}
run: python3 sync_repos.py