LoginSignup
7
7

More than 5 years have passed since last update.

Heroku で bundle update した上で Pull Request させる

Posted at

Heroku で bundle update した上で Pull Request させる?

先日RubyKaigi2013で @kyanny さんのお話を聞いて感銘を受けました。
お話されていた内容の詳細は下記URLで書かれています。

RubyKaigi 2013 kyannys blog

この記事の中ではGemfileのアップデート作業はとても大事な仕事だと説明しています。
非常に共感したのでプライベートのプロジェクトでも導入したいなと思ったのでした。

ちなみにIncrementsはCircle CIを導入しているのでJenkinsに仕事をさせることはできません。

Jenkinsは導入していなくても、1日毎にpull requestを実行出来る環境があれば良いと考えたのでHerokuでできないか調べてみました。(テストはCircle CIやTravis CIのGIthub連携でやってくれる)

Herokuでもできた

Heorkuはappを作成後、デフォルトの.bundleディレクトリを用意するので、その挙動を回避してあげる事でHeroku内でリポジトリをcloneする事ができるようになります。

皆さんでも出来る様にプロジェクトにしてみたので、お試しください。
https://github.com/camelmasa/gemfile-monitor-heroku-app

shの中は簡単なコマンドになっているので、簡単に編集できます。

gemfile-monitor.sh

#!/bin/sh
SHELL=/bin/bash

# monitor github repository
repository='' # example. git@github.com:camelmasa/animate-rails.git

# repository
date=`date '+%Y-%m-%d'`
branch="update-gemfile-${date}"

mv bundle_config .bundle/config
git clone ${repository} repo
cd repo
git checkout -b ${branch}
bundle update
git add Gemfile.lock
git commit -m 'update Gemfile'
git push origin ${branch}
hub pull-request  ${branch}

pull requestはこんな感じで来ます。
こんな感じ

注意点

注意点としては以下。

  • 普段hubコマンドを使用している前提
  • git cloneする際にパスワードを入力しなくても良いようにしないといけない
    • 秘密鍵/公開鍵を作成する際にパスワードを入力しない等
  • 秘密鍵がHeroku上に存在することになる
  • gem sqliteを使用するリポジトリの場合、gem updateで失敗する
    • 回避する方法があれば教えてほしいです ><

まとめ

難点があるので小さなプロジェクトに向いているかもしれませんね。
フィードバックお待ちしてます :)

7
7
0

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
7
7