参考
HubotにGitHubのプルリクエストを自動でアサインさせる - Qiita
https://qiita.com/s-kiriki/items/4b38af4ebd05bad70eb7
本題
上記を参考にして実装しようとしたらPayload URLではまったのでメモ。
Webhookの登録
基本的には参考のとおりなのですが、Payload URL について解説します。
Payload URL には自分のサーバーのhubotへのURLを記述します。
例:http://999.999.999.999:9999/github/pullreq-auto-assign-webhook
そして、このパスが何で決まるかというと
999.999.999.999
自分のサーバーのIPに書き換えて下さい
:9999
hubotのportに書き換えてください。
hubotにはExpressが入っていて、そいつが基本は8080ポートで動くので基本は8080です。
ただし、8080が他のportで使用されている場合は別のportを使用しないといけません
その場合は,hubotRoot/bin/hubot を下記のように書き換えます。
#!/bin/sh
set -e
npm install
export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"
exec node_modules/.bin/hubot --name "myhubot" "$@"
↓
#!/bin/sh
set -e
npm install
export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"
PORT=9999 \
exec node_modules/.bin/hubot --name "myhubot" "$@"
※PORT=の行の最後の\は必要なのでそのまま記述して下さい。あとPORT=の行と次の行は空けないでください。
/github/pullreq-auto-assign-webhook
この部分はまじでなんでもいいです。
以下みたいに、scriptを記述していくのですが、その際にscript内で指定した文字列と同じものを記載すればOKです。
scripts/pullreq-auto-assign-webhook.coffee
module.exports = (robot) ->
...
robot.router.post "/github/pullreq-review-comment", (req, res) ->
サンプル
今見たら bin/hubotに色々設定していたので一応記述しておきます。
#!/bin/sh
set -e
npm install
export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"
HUBOT_GITHUB_TOKEN="********************************************" \
HUBOT_GITHUB_ORG="********" \
HUBOT_GITHUB_REVIEWER_TEAM="00000000" \
HUBOT_GITHUB_WITH_AVATAR="0" \
PORT=9999 \
HUBOT_SLACK_TOKEN="xoxb-***********************************" \
exec node_modules/.bin/hubot --name "name" "$@"