# 開発効率を上げるGitHub Apps + hadolintのすゝめ

- URL: https://tech.fusic.co.jp/posts/2018-12-01-GitHub-Apps-hadolint/
- 公開日: 2018-12-01
- 著者: sakuragawa
- 掲載: Fusic Tech Blog（株式会社Fusic）

> こんにちは、初登場の櫻川です。よろしくお願いします…[続きを読む開発効率を上げるGitHub Apps + hadolintのすゝめ](https://tech.fusic.co.jp/github-apps/%e9%96%8b%e7%99%ba%e5%8a%b9%e7%8e%87%e3%82%92%e4%b8%8a%e3%81%92%e3%82%8bgithub-apps%e3%81%ae%e3%81%99%e3%82%9d%e3%82%81/)<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt -->

---

こんにちは、初登場の櫻川です。よろしくお願いします。

この記事は[Fusic Advent Calendar 2018](https://qiita.com/advent-calendar/2018/fusic) 1日目の記事です。

今回は [@tutida](https://tech.fusic.co.jp/author/uchida/) と一緒にはまっているGitHub Appsによる開発効率アップについてです。  
その中でも、Dockerfileのlintについてです。

## hadolint

Dockerfileで有名なのはこれですかね？  
自分はhadolintを利用してます。

[Dockerfileの静的解析ツールが便利すぎた](https://qiita.com/ryuichi1208/items/d49f3f6ba39c88899049)  
[hadolint](https://github.com/hadolint/hadolint)

使い方とか公式を確認してください。

## 使えたわーい☆

それじゃ楽しくない。  
自動化しようぜ！

gitのhookでいい？みんなで設定なしで楽して使いたいよね。  
やっぱりGitHub Appsだ。

## GitHub Apps + probot + probot/serverless-lambda + hadolint + lambda

この組み合わせが楽ちんです。

**実行イメージ**  
 ![](/uploads/2018-12-01_12h19_14-800x789.png)

一回作っちゃえば後は、GitHubへpushしたタイミングで自動的にチェックしてくれます。  
かなり便利！

## 作り方

1. GitHub Appsを作ります
2. probotをインストールします [Github Apps のサンプルアプリケーションをProbotで作る](https://tech.fusic.co.jp/web/github-apps-%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92probot%e3%81%a7%e4%bd%9c%e3%82%8b/)
3. GitHubの `pull_request.synchronize` イベントを受け取る
4. [list-pull-requests-files](https://developer.github.com/v3/pulls/#list-pull-requests-files) APIを実行してプルリクのファイル一覧を取得する
5. Dockerfileを探す
6. hadolintを実行する
7. 実行結果を [create-a-comment](https://developer.github.com/v3/pulls/comments/#create-a-comment) APIでコメントを書き込む
8. 完成！

## これ以外にもこんなことで効率アップ！

- GitHubテンプレートの自動設置
- CI用の設定ファイルの自動設置
- 初期Labelの自動設置
- レビュー依頼の自動化
- 文言チェックの自動化  
等々

きっと @tutida がまとめてくれるはずｗ

## まとめ

GitHub Apps便利！  
GitHubで公開したかったけどリファクタ間に合わなかったｗ  
そのうち公開します。

<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->
