59 lines
1.6 KiB
YAML
59 lines
1.6 KiB
YAML
name: "同步 A → B"
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
paths:
|
|
- 'configs/A_to_B.yaml'
|
|
- 'scripts/sync_tool.py'
|
|
- '.gitea/workflows/sync_A_to_B.yml'
|
|
workflow_dispatch:
|
|
schedule:
|
|
# 每天凌晨2点执行
|
|
- cron: '0 2 * * *'
|
|
|
|
env:
|
|
CONFIG_FILE: 'configs/A_to_B.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
|
|
|
|
- name: 验证配置文件
|
|
run: |
|
|
if [ ! -f "${{ env.CONFIG_FILE }}" ]; then
|
|
echo "错误: 配置文件 ${{ env.CONFIG_FILE }} 不存在!"
|
|
exit 1
|
|
fi
|
|
echo "✓ 配置文件已找到: ${{ env.CONFIG_FILE }}"
|
|
|
|
- name: 执行同步 A → B
|
|
env:
|
|
SYNC_A_B_USERNAME: ${{ secrets.SYNC_A_B_USERNAME }}
|
|
SYNC_A_B_TOKEN: ${{ secrets.SYNC_A_B_TOKEN }}
|
|
run: |
|
|
echo "================================================================================"
|
|
echo "开始同步: A → B"
|
|
echo "使用配置: ${{ env.CONFIG_FILE }}"
|
|
echo "环境前缀: SYNC_A_B"
|
|
echo "================================================================================"
|
|
python3 scripts/sync_tool.py ${{ env.CONFIG_FILE }} --env-prefix SYNC_A_B
|