name: Sync Mirror Repository

on:
  schedule:
    - cron: '0 */8 * * *'  # 每小时同步一次
  workflow_dispatch:  # 允许手动触发

jobs:
  mirror:
    runs-on: ubuntu-latest

    timeout-minutes: 10  # 设置作业的超时时间为10分钟

    steps:
      - name: Checkout target repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 1  # 获取完整的提交历史

      - name: Mirror source repository
        uses: wearerequired/git-mirror-action@v1
        with:
          source-repo: "https://gitlink.org.cn/JointCloud/pcm-coordinator.git"  # 源仓库的URL
          destination-repo: "git@github.com:${{ github.repository }}.git"  # 目标仓库的URL
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}