LoginSignup
0
0

More than 3 years have passed since last update.

GitHub Actions で cron で upstream repo 自動追随しようとしたがうまくいかない

Posted at

背景

  • 自身ではコミット権がない, active に開発されている github にある repo を fork で追随している
    • llvm-project や, pytorch など
  • 自前 fork repo にいろいろオレオレ改変を入れている
    • e.g. CI ファイルとか

毎回(e.g. 毎日) git pull するのも面倒なので, GitHub Actions で自動追随しようと思いました. 現状うまく行ってません.

cron

GitHub Actions では, cron で定期処理ができます.

トラッキングしたい upstream repo に変更があったら, fork 先に知らせるみたいな機能は無いっぽいようなので, cron で定期チェックしてみます.

時刻は UTC-0 基準のようです.

うまく動くか試すのに, 1 分単位とかでやったときに, エラーがでるとメール通知がすごいことになるのでご注意ください.

うまくいかない例

以下のような記述をしましたが, うまくいきませんでした.
(毎日 4:00 am に実行する)

通常 checkout だと, unrelated histories エラーがでるので, --allow-unrelated-histories をつけて見ましたが, 結局は conflict が発生してマージできませんでした.

name: sync with upstream

on:
  schedule:
    - cron: '* 4 * * *'

jobs:
  sync:

    runs-on: ubuntu-latest

    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: sync
        run: |
          git config --global user.email "dummy@dummy.com"
          git config --global user.name "github actions"
          git remote add upstream https://github.com/llvm/llvm-project
          git fetch upstream
          git checkout master
          # TODO: Investigate why `--allow-unrelated-histories` required.
          # TODO: Only push there is a change
          git pull upstream master --allow-unrelated-histories && git push origin master

TODO

  • git に, 自身の repo はどこかの fork であることを知らせればいけるか?
    • hub コマンドでなにかいけるかも?
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0