gitHub中自动同步fork

这里以k3s为例 先fork https://github.com/rancher/k3s 然后创建action yml文件

vi .github/workflows/fork-sync.yml
name: Merge upstream branches
on:
  push:
  schedule:
     # actually, ~5 minutes is the highest
     # effective frequency you will get
    - cron:  '0 1 * * *'
jobs:
  merge:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Merge upstream
        run: |
          git config --global user.name '21ki'
          git config --global user.email '21kixc@gmail.com'
          # "git checkout master" is unnecessary, already here by default
          git pull --unshallow  # this option is very important, you would get
                                # complains about unrelated histories without it.
                                # (but actions/checkout@v2 can also be instructed
                                # to fetch all git depth right from the start)
          @添加上游仓库如果是其他上游仓库自行修改
		  git remote add upstream https://github.com/rancher/k3s.git
          git fetch upstream
          # Neither forget the -b opt,
          # the feature/x ref is ambiguous at this stage
          git checkout master
          git merge --no-edit upstream/master
          git push origin master
          #git checkout master
          #git merge --no-edit upstream/master
          #git push origin master
          
          #sync tag
          git fetch upstream --tags
          git push --tags
          # etc

gitee同步github仓库示例

on:
  push #推送时触发
  #push:
  # 定时任务触发
  schedule:
    # 每天北京时间9点跑
    # Runs at 01:00 UTC (9:00 AM Beijing) every day
    - cron:  '0 1 * * *'
name: sync / gitee
jobs:
  run:
    name: Run
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source codes
        uses: actions/checkout@v1
      - name: Mirror Github to Gitee with white list
        uses: Yikun/hub-mirror-action@master
        with:
          src: github/21ki
          dst: gitee/myki
          dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
          dst_token:  ${{ secrets.GITEE_TOKEN }}
          clone_style: "ssh"
          white_list: "win,linux,vos"
          static_list: 'win,linux,vos'
          force_update: true
          debug: true

gitee同步参考链接