Skip to content

GitHub Actions Workflow 自动同步 fork 上游仓库

GitHub Actions Workflow for auto sync from upstream

修改以下git config信息和upstream上游仓库,并设置cron定时同步或本人star仓库触发同步.

master 分支版

yml
name: Merge upstream branches
on:
  push:
  schedule:
    - cron:  '0 18 * * *'
  watch:
    types: [started]
jobs:
  merge:
    runs-on: ubuntu-latest
    if: github.event.repository.owner.id == github.event.sender.id
    steps:
      - uses: actions/checkout@v2.3.5
      - name: Merge upstream
        run: |
          git config --global user.name 'name'
          git config --global user.email 'name@email.com'
          git pull --unshallow
          git remote add upstream https://github.com/xxxxx/xxxxx.git
          git fetch upstream
          git checkout master
          git merge --no-edit upstream/master
          git push origin master
          git fetch upstream --tags
          git push --tags

main 分支版

yml
name: Merge upstream branches
on:
  push:
  schedule:
    - cron:  '0 18 * * *'
  watch:
    types: [started]
jobs:
  merge:
    runs-on: ubuntu-latest
    if: github.event.repository.owner.id == github.event.sender.id
    steps:
      - uses: actions/checkout@v2.3.5
      - name: Merge upstream
        run: |
          git config --global user.name 'name'
          git config --global user.email 'name@email.com'
          git pull --unshallow
          git remote add upstream https://github.com/xxxxx/xxxxx.git
          git fetch upstream
          git checkout main
          git merge --no-edit upstream/main
          git push origin main
          git fetch upstream --tags
          git push --tags