Files
code-sync-project/.gitea/workflows/sync_B_to_C.yml
2025-11-22 17:31:53 +08:00

59 lines
1.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: "同步 B → C"
on:
push:
branches:
- master
paths:
- 'configs/B_to_C.yaml'
- 'scripts/sync_tool.py'
- '.gitea/workflows/sync_B_to_C.yml'
workflow_dispatch:
schedule:
# 每天凌晨3点执行在 A→B 之后)
- cron: '0 3 * * *'
env:
CONFIG_FILE: 'configs/B_to_C.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: 执行同步 B → C
env:
SYNC_B_C_USERNAME: ${{ secrets.SYNC_B_C_USERNAME }}
SYNC_B_C_TOKEN: ${{ secrets.SYNC_B_C_TOKEN }}
run: |
echo "================================================================================"
echo "开始同步: B → C"
echo "使用配置: ${{ env.CONFIG_FILE }}"
echo "环境前缀: SYNC_B_C"
echo "================================================================================"
python3 scripts/sync_tool.py ${{ env.CONFIG_FILE }} --env-prefix SYNC_B_C