@ijin

[Michael H. Oshita]

Ruboty-github_pr_releaseを作った

よくプロジェクトでstagingproductionブランチにリリース用のpull requestを送ってmergeする事でCircleCIが走って自動デプロイするような仕組みを入れているんだけど、いちいちGitHub上でポチポチ画面を押すのが面倒くさいのと、久しぶりにやるとbasecompareとで混乱しそうになるので、ChatOpsを導入して効率化してみました。

Slackと連携できるボットにはrubotyを選択。

プラグイン周りではruboty-githubがあるけど、微妙に要求に応えれなかったので少し拡張したruboty-github_pr_releaseを作りました。久々のgem公開。

Install

Gemfile
1
gem 'ruboty-github_pr_release'

Release pull request

create

pull requestを作成。それまでmergeしたfeature branch等のタイトルが集約される

1
ruboty release from <org/repo:from_branch> to <org/repo:to_branch>

update

pull request作成後に新たなコミットを取り込む時やタイトルを変更したい時

1
ruboty update release from <org/repo:from_branch> to <org/repo:to_branch> as "new title"

deploy

pull requestをmergeしてデプロイ

1
ruboty deploy release from <org/repo:from_branch> to <org/repo:to_branch>

alias

ruboty-aliasruboty-scoped_aliasを使うとさらにコマンドを短縮して便利です。scopedにすると部屋毎にプロジェクトを割り当てたりも可能。

1
2
ruboty scoped alias release production -> release from ijin/test:staging to ijin/test:production
ruboty scoped alias deploy production -> deploy release from ijin/test:staging to ijin/test:production

簡単!

注意

  • 開発branchにmergeされたサマリーを作成するのでGit/GitHub flow等が前提(直接branchにコミットしない)
  • mergeをrevertしてしまうと、branch間の差分が取れなくなるので開発branch(develop等)から修正fixを新たにpull requestとして送る必要がある
  • ruboty-githubは個々人で認証をしているので、チャネルではなく、rubotyに対してDMで認証するべき(remember my github token xxx)

参考

おまけ

ほとんど作り終えたところでほぼ同じ機能を持ったincrements/ruboty-qiita-githubに気づいたけど、気にせずリリースしちゃった。一応merge周りはこっちの方が若干楽なので。。

Comments