Sync-Fork.yaml (2774B)
1 # Follow Changes of Forked/Upstream Repository. 2 # 3 # This workflow rebase-marge changes from upstream's master to origin's master. 4 # - Ref: 5 # - https://stackoverflow.com/a/61574295/12102603 by N1ngu @ StackOverflow (EN) 6 # - https://qiita.com/KEINOS/items/3bcaa6cea853f6b63475 by KEINOS @ Qiita (JA) 7 8 name: Merge upstream branches 9 10 # Triggers the action as scheduled 11 on: 12 # Runs on 10 minutes past every hour(毎 n 時 10 分に実行) 13 schedule: 14 # Ref: 15 # - https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule 16 # - https://crontab.guru/examples.html 17 # Cron format: 18 # ┌───────────── minute (0 - 59) 19 # │ ┌───────────── hour (0 - 23) 20 # │ │ ┌───────────── day of the month (1 - 31) 21 # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) 22 # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) 23 # │ │ │ │ │ 24 # │ │ │ │ │ 25 # │ │ │ │ │ 26 # * * * * * 27 - cron: '10 */1 * * *' 28 29 jobs: 30 merge: 31 runs-on: ubuntu-latest 32 steps: 33 - uses: actions/checkout@v2 34 - name: Merge upstream 35 # 以下の設定を変更してください。REPO_FORK が fork 元です。 36 env: 37 NAME: KEINOS 38 EMAIL: github+fork-qiita-news@keinos.com 39 REPO_FORK: https://github.com/microsoft/winget-cli.git 40 # 追従処理 41 run: | 42 git config --global user.name ${NAME} 43 git config --global user.email ${EMAIL} 44 45 : # git rebase をデフォルトに設定 46 git config --global pull.rebase merges 47 48 : # "git checkout master" は不要です。デフォルトで設定されます。 49 : # しかし下記の設定は重要です。過去のコミットが取得されないと、コミット歴に不統合が 50 : # 発生した旨のエラーが出ます。 51 git pull --unshallow 52 53 : # フォーク元のリポジトリをリモート先として "upstream" に命名 54 git remote add upstream ${REPO_FORK} 55 56 : # upstream のブランチをローカルに取得 57 git fetch upstream 58 59 : # marster ブランチの変更をマージし、clone 元の master に push 60 : # ブランチ名を main などに変更していたり、別のブランチにしている場合は注意 61 git checkout master 62 git merge --no-edit upstream/master 63 git push origin master