blog.unresolved.xyzblog.unresolved.xyz

CircleCIでyarn upgradeやbundle updateを実行してプルリクを作ってもらう方法

Thu Jul 26 2018

    本当にライフチェンジングなので、やっていない方はぜひ試してみてください。

    有志が以下のような素晴らしいツールを公開してくれているので、これらをありがたく使わせていただきましょう。

    CircleCIで依存ライブラリのアップデートを回す

    自分はこのようなconfig.ymlを使っています。

    version: 2
    jobs:
      build:
        # your default build scripts.
      bundle-update:
        docker:
          - image: circleci/ruby:2.5.1-node
        steps:
          - checkout
          - restore_cache:
              name: Restore bundler cache
              key: rails-demo-{{ checksum "Gemfile.lock" }}
          - run:
              name: Setup requirements for continuous bundle update
              command: gem install -N circleci-bundle-update-pr
          - deploy:
              name: Continuous bundle update
              command: circleci-bundle-update-pr $GIT_USER_NAME $GIT_USER_EMAIL
    
      yarn-upgrade:
        docker:
          - image: node:6-alpine
        steps:
          - run: apk add --update --no-cache git openssh-client
          - checkout
          - run: yarn global add ci-yarn-upgrade
          - run: yarn install
          - run: ci-yarn-upgrade --execute --verbose --latest;
    
    workflows:
      version: 2
      build_and_test:
        jobs:
          - build
      nightly-bundle-update:
        triggers:
          - schedule:
              cron: "0 0 * * *"
              filters:
                branches:
                  only: master
        jobs:
          - bundle-update
      nightly-yarn-upgrade:
        triggers:
          - schedule:
              cron: "0 0 * * *"
              filters:
                branches:
                  only: master
        jobs:
          - yarn-upgrade

    CircleCI上のcronはUTCで回るので、日本だとAM9時に処理が実行されます。

    サービスにやらせるならこちら

    おそらく王道はこのあたりでしょうか。

    どちらもセルフホスティングできるはずなので、費用をかけたくない場合は自分で立ててしまえば済むと思います。