LoginSignup
434
283

More than 1 year has passed since last update.

SlackとGitHubを連携してissueコメントやプルリク通知をチャンネルに流す方法(2020年版)

Last updated at Posted at 2020-02-24

以前書いたSlackとGitHub連携記事の情報が古くなっており、設定方法も色々と変わっていたため、2020年2月時点での手順をまとめておきます。

本記事の更新は停止しているため、最新版はZennの記事をご参照ください。

SlackにGitHubアプリをインストールする

SlackのApp Directoryで「GitHub」を検索、もしくはslack.github.comにアクセスし「Add to Slack」をクリックします。
スクリーンショット 2020-02-24 20.07.30.png

対象ワークスペースにGitHubアプリをインストールします。

通知を使用するチャンネルを選んで「Install」をクリック。実際のチャンネル紐付けは後述の手順で行うため、ここでは「All Public Channels」を選択しておくのが無難です。

スクリーンショット_2020-02-24_20_08_26.jpg

ワークスペースにGitHubアプリが追加されます。
スクリーンショット 2020-02-24 20.08.57.png

GitHubアカウントとの接続を行う

続いてGitHubアカウントとの接続を行います。以下コマンドでサインインのワークフローを呼び出します。

/github signin

「Connect GitHub account」をクリック。

スクリーンショット 2020-02-24 20.11.24.png

Web画面が開くので、対象ワークスペースを確認し「Connect GitHub account」をクリック。
スクリーンショット_2020-02-24_20_11_37.jpg

これでGitHubアカウントとSlackワークスペースの接続連携が完了です。

スクリーンショット 2020-02-24 20.11.47.png

リポジトリの購読を開始する

GitHubリポジトリの通知を流したいチャンネルに移動し、以下コマンドを叩きます。

/github subscribe owner/repo
  • owner:オーナー名
  • repo:リポジトリ名

これで購読開始となります。

スクリーンショット 2020-02-24 20.18.07.png

簡単ですね。

通知をカスタマイズする

デフォルトで通知される機能は以下のとおり。

  • issues (イシュー)
  • pulls (プル)
  • statuses (ステータス)
  • コミット
  • deployments (デプロイメント)
  • public (パブリック)

以下の機能はデフォルトでは通知されません。

  • reviews (レビュー)
  • comments (コメント)
  • branches (ブランチ)
  • commits:* (すべてのコミット)

コメントやブランチ操作など、わりと通知してほしい機能が省かれているため、手動で追加します。

2021/5/11追記
commits:all -> commits:* に変更(@takasehideki さん、情報共有ありがとうございます!)

Note: Previously we you might have used commits:all to represent all branches. 'all' is no longer a reserved keyword. Going forward, you need to use '*' to represent all branches. If you have already configured with 'commits:all' previosly, dont worry, it will continue to work until you update the commits configuration.

integrations/slack: Bring your code to the conversations you care about with the GitHub and Slack integration

通知の追加

通知する機能の追加は、以下コマンドで行います。

/github subscribe owner/repo [機能]

デフォルトで通知されない機能すべてを流すなら以下コマンドを叩きましょう。

/github subscribe owner/repo reviews,comments,branches,commits:*

This channel will get notifications from のメッセージに続き、現在通知が有効となっている機能が羅列されます。

スクリーンショット 2020-02-24 21.11.44.png

これでGitHubリポジトリに行われたすべての操作がSlackチャンネルに流れるようになります。

スクリーンショット 2020-02-24 20.27.43.png

やったぜ。

通知の削除

特定機能の通知解除は以下コマンドで行えます。

/github unsubscribe owner/repo [機能]

通知が不要な機能は削除しておきましょう。

Slack連携はいいぞ

直近の操作ログを確認するのにも便利ですし、issueコメントやプルリクレビューのやりとりをSlackで検索できるのが超絶便利です。

開発が活発なリポジトリでは頻繁にログが流れてきますので、通知専用チャンネルを作っておくと良いでしょう。

Slackを使われている開発者の方は、ぜひGitHubと連携して開発効率をアップしていきましょう:muscle:

参考

GitHub と Slack を連携させる | Slack
integrations/slack: Bring your code to the conversations you care about with the GitHub and Slack integration

434
283
3

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