通过reposync方式进行代码同步
创建新仓库
填入Repository name后点击最下方的Create repository即可完成创建
自己创建工作流
在创建完成页面点击Actions再点击set up a workflow yourself

复制 https://github.com/insChow/auto_repo-sync/blob/master/.github/workflows/sync-scripts.yml 里面的代码
复制完毕后直接点击右上角的Start commit后直接Commit new file即可

申请PAT
点击 GitHub 用户设置页面 最下方的Developer setting ,然后选择 Personal access tokens(点击快捷到达指定页面) 来生成一个 token,把 repo和workflow 两部分勾上即可。

点击最下面的创建按钮后,图示部分即为你的PAT(图示的已经删除了,仅为演示),复制下来马上就要使用了

填写PAT到Secrets
申请完毕后,在分支中点击Settings-Secrets-New secret

name填PAT,Value填入上方申请到的PAT,保存即可

手动触发一次代码同步
点击Actions,找到指定的脚本,按图示运行一次

等待两分钟左右,能够发现代码全部同步过来了

Enjoy
操作到这一步,表示您已经全部完成了
dawangshimoluo的代码如下
代码如下
# File: .github/workflows/repo-sync.yml
name: sync- danwangshimoluo -scripts
on:
schedule:
- cron: '1 0,15 * * *'
workflow_dispatch:
watch:
types: started
push:
branches: [ main ]
repository_dispatch:
types: sync- danwangshimoluo -scripts
jobs:
repo-sync:
env:
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: sync danwangshimoluo -scripts
uses: repo-sync/github-sync@v2
if: env.PAT
with:
source_repo: "https://github.com/danwangshimoluo/JdScripts.git"
source_branch: "main"
destination_branch: "main"
github_token: ${{ secrets.PAT }}
THE END
二维码
