AI摘要:文章介绍了一个用于自动同步 GitHub 仓库的工作流脚本,通过定时任务和事件触发实现同步,使用了个人访问令牌(PAT)作为身份验证。该脚本还提供了一个用于将 GitHub 仓库同步到 Gitee 的操作链接。
Powered by 部落Bot.

工作流脚本

# File: .github/workflows/repo-sync.yml
name: 🔄自动同步🔄
on:
  schedule:
    - cron: '0 */1 * * *'
  workflow_dispatch:
  watch:
    types: started
  repository_dispatch:
    types: repo-sync
jobs:
  repo-sync:
    env:
      PAT: ${{ github.event.client_payload.PAT || secrets.PAT }} #此处PAT需要申请,教程详见:https://www.jianshu.com/p/bb82b3ad1d11
    runs-on: ubuntu-latest
    if: github.event.repository.owner.id == github.event.sender.id
    steps:
      - uses: actions/checkout@v2
        with:
          persist-credentials: false

      - name: 开始🔄自动同步🔄
        uses: repo-sync/github-sync@v2
        if: env.PAT
        with:
          source_repo: "https://github.com/shuye73/MyActions.git" #此处修改源repo
          source_branch: "main"
          destination_branch: "main"
          github_token: ${{ github.event.client_payload.PAT || secrets.PAT }}
PAT:Personal access tokens

Github 到 Gitee

https://github.com/Yikun/hub-mirror-action