継続は力なり

タイトル通り定期的な更新を心掛けるブログです。

【Hubot】HubotをHerokuにデプロイ

タダです。

この前、セットアップしたHubotをいじっていきます。
sadayoshi-tada.hatenablog.com


予め、次の準備ができている状態です。

  • 自分のSlackアカウントがある
  • Herokuのアカウントがある
  • ローカルのマシンにHeroku toolbeltを入れている

Herokuにデプロイする

Gitのコマンドの内容はともかくとして、実行した結果を貼っていきます。
とりあえず、 `git push` したので、ソースはHerokuに載っている状態です。

$ git init
Reinitialized existing Git repository in /xxxx/xxxx/god-knows/.git/

$ git add -A

$ git commit -m "initial commit"
[master 4c0a584] initial commit
 Committer: Sadayoshi Tada <tada@Sadayoshi-no-MacBook-Pro.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+), 1 deletion(-)

$ heroku create
heroku-cli: Installing CLI... 19.73MB/19.73MB
Enter your Heroku credentials.
Email: xxxx@gmail.com
Password (typing will be hidden):
Logged in as xxxx@gmail.com
Creating app... done, ⬢ fast-thicket-12164
https://fast-thicket-xxxx.herokuapp.com/ | https://git.heroku.com/fast-thicket-xxxx.git

$ git push heroku master
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (17/17), 6.19 KiB | 0 bytes/s, done.
Total 17 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  0.10.x
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 0.10.x via semver.io...
remote:        Downloading and installing node 0.10.45...
remote:        Using default npm version: 2.15.1
remote:
remote: -----> Restoring cache
remote:        Skipping cache restore (new runtime signature)
remote:
remote: -----> Building dependencies
remote:        Pruning any extraneous modules
remote:        Installing node modules (package.json)
remote:
remote:        > ws@0.4.31 install /tmp/build_791c79c9c2444c345d4cfc3c59940841/node_modules/hubot-slack/node_modules/slack-client/node_modules/ws
remote:        > (node-gyp rebuild 2> builderror.log) || (exit 0)
remote:
remote:        make: Entering directory `/tmp/build_791c79c9c2444c345d4cfc3c59940841/node_modules/hubot-slack/node_modules/slack-client/node_modules/ws/build'
remote:        CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
remote:        SOLINK_MODULE(target) Release/obj.target/bufferutil.node
remote:        COPY Release/bufferutil.node
remote:        CXX(target) Release/obj.target/validation/src/validation.o
remote:        SOLINK_MODULE(target) Release/obj.target/validation.node
remote:        COPY Release/validation.node
remote:        make: Leaving directory `/tmp/build_791c79c9c2444c345d4cfc3c59940841/node_modules/hubot-slack/node_modules/slack-client/node_modules/ws/build'
remote:        hubot-maps@0.0.2 node_modules/hubot-maps
remote:
remote:        hubot-help@0.2.0 node_modules/hubot-help
remote:
remote:        hubot-shipit@0.2.0 node_modules/hubot-shipit
remote:
remote:        hubot-diagnostics@0.0.1 node_modules/hubot-diagnostics
remote:
remote:        hubot-pugme@0.1.0 node_modules/hubot-pugme
remote:
remote:        hubot-rules@0.1.1 node_modules/hubot-rules
remote:
remote:        hubot-google-images@0.2.6 node_modules/hubot-google-images
remote:
remote:        hubot-google-translate@0.2.0 node_modules/hubot-google-translate
remote:
remote:        hubot-heroku-keepalive@1.0.2 node_modules/hubot-heroku-keepalive
remote:
remote:        hubot-redis-brain@0.0.3 node_modules/hubot-redis-brain
remote:        └── redis@0.8.4
remote:
remote:        hubot-slack@3.4.2 node_modules/hubot-slack
remote:        └── slack-client@1.4.1 (log@1.4.0, coffee-script@1.9.3, ws@0.4.31)
remote:
remote:        hubot@2.19.0 node_modules/hubot
remote:        ├── optparse@1.0.4
remote:        ├── log@1.4.0
remote:        ├── cline@0.8.2
remote:        ├── scoped-http-client@0.11.0
remote:        ├── async@0.9.2
remote:        ├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, has-ansi@2.0.0, strip-ansi@3.0.1)
remote:        ├── coffee-script@1.6.3
remote:        ├── connect-multiparty@1.2.5 (qs@2.2.5, on-finished@2.1.1, type-is@1.5.7, multiparty@3.3.2)
remote:        └── express@3.21.2 (escape-html@1.0.2, merge-descriptors@1.0.0, cookie@0.1.3, cookie-signature@1.0.6, utils-merge@1.0.0, fresh@0.3.0, methods@1.1.2, range-parser@1.0.3, vary@1.0.1, basic-auth@1.0.4, parseurl@1.3.1, content-type@1.0.2, etag@1.7.0, content-disposition@0.5.0, commander@2.6.0, depd@1.0.1, debug@2.2.0, proxy-addr@1.0.10, send@0.13.0, mkdirp@0.5.1, connect@2.30.2)
remote:
remote:        hubot-scripts@2.17.2 node_modules/hubot-scripts
remote:        └── redis@0.8.4
remote:
remote: -----> Caching build
remote:        Clearing previous node cache
remote:        Saving 2 cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (nothing to cache)
remote:
remote: -----> Build succeeded!
remote:        ├── hubot@2.19.0
remote:        ├── hubot-diagnostics@0.0.1
remote:        ├── hubot-google-images@0.2.6
remote:        ├── hubot-google-translate@0.2.0
remote:        ├── hubot-help@0.2.0
remote:        ├── hubot-heroku-keepalive@1.0.2
remote:        ├── hubot-maps@0.0.2
remote:        ├── hubot-pugme@0.1.0
remote:        ├── hubot-redis-brain@0.0.3
remote:        ├── hubot-rules@0.1.1
remote:        ├── hubot-scripts@2.17.2
remote:        ├── hubot-shipit@0.2.0
remote:        └── hubot-slack@3.4.2
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 8.9M
remote: -----> Launching...
remote:        Released v3
remote:        https://fast-thicket-12164.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/fast-thicket-12164.git
 * [new branch]      master -> master

Herokuの環境設定を行う

以下のような内容を実行しました。

$ heroku config:set \
> HUBOT_SLACK_TOKEN=xxxxxxxxxx \
> HUBOT_SLACK_TEAM=taddyteam \
> HUBOT_SLACK_BOTNAME=god-knows
Heroku CLI submits usage information back to Heroku. If you would like to disable this, set `skip_analytics: true` in /Users/tada/.heroku/config.json
Setting HUBOT_SLACK_TOKEN, HUBOT_SLACK_TEAM, HUBOT_SLACK_BOTNAME and restarting ⬢ fast-thicket-12164..Setting HUBOT_SLACK_TOKEN, HUBOT_SLACK_TEAM, HUBOT_SLACK_BOTNAME and restarting ⬢ fast-thicket-12164... done, v4
HUBOT_SLACK_BOTNAME: god-knows
HUBOT_SLACK_TEAM:    taddyteam
HUBOT_SLACK_TOKEN:   xxxxxxxxxx

実際に話しかけてみる

おっ反応返ってきました!
f:id:sadayoshi_tada:20160517015140p:plain

次回

次は、Hubotのスクリプトを作っていきます