Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hubot事例
Search
ryonext
January 21, 2015
Technology
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Hubot事例
弊社のHubotとSlack連携の活用事例です。
ryonext
January 21, 2015
More Decks by ryonext
See All by ryonext
AWS Lambda の Ruby 対応
ryonext
0
280
TwitterのList編集しやすいやつ作った
ryonext
0
1.8k
validationについて
ryonext
1
860
AWS Lambda と API GatewayでRails使わずに済んだ話
ryonext
8
4.4k
capistrano-bundle_rsync使ったらオートスケールが高速化した話
ryonext
8
2.6k
PumaとUnicornで最近自分が理解したこと
ryonext
13
9.6k
Redisでバッチ処理を冗長化しつつ排他制御
ryonext
0
2.2k
CircleCIとwercker
ryonext
3
1.3k
rubykaigi 3day interactive white board
ryonext
2
410
Other Decks in Technology
See All in Technology
OAuth SPIFFE Client Authentication(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
380
型落ちシンクライアント端末のPoEモジュールを自作したかった話
logica0419
0
530
AI × Datadog MCP でコスト削減まで実現した Metric Streams の導入
three_mouth_ago
0
110
本番に近いテストをもっと手軽に - Postmanで広がるAPIテストの世界 / Expanding the World of API Testing with Postman
yokawasa
1
170
Distributed Transactions Under Fire: Building a Zero-Oversell Flash Sale Platform with Amazon Aurora DSQL
yama3133
1
110
顧客の要望は2次情報である 〜アンテナを張るFDEの構造論〜
noriakioji
5
1.1k
紙 to デジタル
ichien178
0
440
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
470
Point Cloud as a Foreign Language for Multi-modal Large Language Model
takmin
0
330
カーネルまで探検して理解するふたつの自動計装
sumiyae
0
340
Microsoft MVP プログラムを紹介するから目指す人増えてくれ
tsubakimoto_s
0
160
Guerilla InnerSource in enterprises, during the AI hype
onenashev
PRO
0
120
Featured
See All Featured
Being A Developer After 40
akosma
91
590k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
220
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
520
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
230
Site-Speed That Sticks
csswizardry
13
1.5k
Are puppies a ranking factor?
jonoalderson
2
3.9k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
640
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
360
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Designing for Performance
lara
611
70k
Test your architecture with Archunit
thirion
2
2.4k
Transcript
ฐࣾͷHubotࣄྫ
ࣗݾհ Twitter ID: ryonext Unicon ͱ͍͏ձࣾͰRailsॻ͍ͯ·͢ɻ PS4ങ͍·ͨ͠ 2014ՆΠϕΫϦΞ·Ͱ͙ͬͨΒ͍ͷఏಜͩ ͚Ͳ͖ͬͺΓΊͨͷͰ؋͜ΕΞχϝݟͯ·ͤΜ
Hubotࣄྫ
develop ͔Β master ͷ pull request Λ࡞Δ ඞཁͳαʔϏε Circle CI
ͪΖΜ J但 Ͱ͍͚Δ masterʹϚʔδ͞ΕͨΒ ͦͷ··ຊ൪σϓϩ Π·ͰΔΑ͏ʹͯ͠Δલఏ
σϓϩΠ͍ͨ͠ͱ͖ʹ develop => master ͷ pull req Λ࡞Δͱ͍͏ϧʔνϯϫʔΫ͕ͳ͘ͳ Γੜ࢈ੑͷ্ʹͭͳ͕Δ
pull req ҰཡΛग़͢ hubot show org-pulls ͱ͍͏ίϚϯυ ͜ΕΛͬͯΔ hubot-scripts/github-pulls.coffee at
master · github/hubot-scripts https:/ /github.com/github/ hubot-scripts/blob/master/src/scripts/github- pulls.coffee ࠓ্͕͍ͬͯΔpull requestΛશ෦ग़͢ ޙड़ͷ cron ͱΈ߹Θͤͯ͏͖
ΤϯδχΞ͕ࣗൃతʹpull requestΛݟʹߦ͘ඞཁ͕ͳ͘ͳΓɺ͔͠ཹ͍ͯ͠Δpull request Λݟ͚ͭΔ͜ͱՄೳʹͳΓੜ࢈ੑͷ্ʹͭͳ͕Δ
cron ఆظతʹಛఆͷൃݴΛͤ͞Δ ͜ΕͬͯΔ ncb000gt/node-cron https:/ / github.com/ncb000gt/node-cron ձٞͷϦϚΠϯυΛͨ͠Γɺલड़ͷpull req ҰཡΛݺͼग़ͨ͠Γɺ͍ํࣗ༝ࣗࡏ
ఆظతʹඞཁͳॲཧΛࣗಈ࣮ߦͯ͘͠ΕΔ͜ͱʹΑΓੜ࢈ੑͷ্ʹͭͳ͕Δ
cronࣄྫ1 pull requestͷ௨ ຖܾ·ͬͨ࣌ؒʹͳͬͨΒ hubot show org-pulls Λ࣮ߦ͠ɺpull request ҰཡΛ
ग़͢ ຖܾ·ͬͨ࣌ؒʹ͍ͬͯΔpull requestΛදࣔ͢Δ͜ͱʹΑΓɺϨϏϡʔ͕ଅਐ͞Εੜ࢈ੑͷ ্ʹͭͳ͕Δ
cronࣄྫ2 ேձ&༦ձ + Google Hangouts URLͷ௨ ܾ·ͬͨ࣌ؒʹேձ/༦ձͷ௨ͱɺϦϞʔτ ۈऀ༻ʹGoogle HangoutsͷURLΛߘ
͢Δ͜ͱʹΑΓεϜʔζͳձٞͷ։͕࢝Ͱ͖Δ
ேձʗ༦ձʹΕΔ͜ͱ͕ͳ͘ͳΓɺHangoutsͷURLΛ୳͢ख͕ؒল͚ͯੜ࢈ੑͷ্ʹͭͳ͕Δ
cronࣄྫ 3 9࣌ʹͳͬͨΒࠓ1ؤுΔܾҙΛࣔ͢ը૾ ΛషΔ ࠓҰؤுΕͦ͏ͳը૾ΛݟΔ͜ͱʹΑΓੜ࢈ੑ্ʹͭͳ͕Δ ͨͩ͠ϑϨοΫε͔ͩΒ9͔࣌Βಇ͍͍ͯΔਓ͕গͳ͍
cronࣄྫ3 ͓ͭͷ࣌ؒΛ௨͢Δ 15࣌Λ௨͢Δ͜ͱͰɺΤϯδχΞʹิڅΛଅ͠ɺੜ࢈ੑͷ্ʹͭͳ͕Δ
cronࣄྫ4 ਐḿͷ֬ೝ ϥϯνΛ৯ͯɺ͓ͭΛ৯ͯɺੜ࢈ੑ͕ۃݶ·Ͱߴ·ͬͨΤϯδχΞ͕ͦͷྗΛ༨͢͜ͱແ͘ൃش͠ ͨ͋ͨΓͰͦͷՌΛ֬ೝ͢Δ͜ͱͰϞνϕʔγϣϯ͕Ξοϓ͠ɺੜ࢈ੑͷ্ʹͭͳ͕Δ
cronࣄྫ5 ՖۚΛ௨͢Δ ͨ͠ͳΊΔ ༵ۚͷָ͠͞Λ௨͢ΔͱͱʹɺؾΛҾ͖కΊΔ͜ͱ͕Ͱ͖ੜ࢈ੑͷ্ʹͭͳ͕Δ
͔͜͜Βৄࡉฤ
શମߏ GitHubͷνʔϜΞΧϯτ͕2ͭ͋ΔͨΊɺऔ ಘ༻ͷhubot͕2ମ Cron༻ͷhubot͕1ମ mention༻ʹslackbotΛ׆༻
શମߏɺϦϙδτϦͱ ಈ࡞ڥฤ GitHubcron༻ͷhubotͰ1ϦϙδτϦɺͦ ΕҎ֎ͷhubotͰ1ϦϙδτϦ Herokuʹcron༻Ͱ1, ͦΕҎ֎༻Ͱ2ͭͬ ͯɺڥมͰΞΫηε͢ΔGitHubΛ͍ ͚͍ͯΔ
CronҎ֎༻ͷڥม
Cron༻ͷڥม
develop͔Βmasterͷ pull req ͜Μͳײ͡ͷίʔυ 18 module.exports = (robot) -> 19
github = require("githubot")(robot) 20 robot.respond /deploy ?(.+)/i, (msg) -> 21 repo = msg.match[1] 22 url_api_base = "https://api.github.com" 23 data = { 24 "title": "deploy", 25 "head": "develop", 26 "base": "master" 27 } 28 ghOrg = process.env.HUBOT_GITHUB_ORG 29 url = "#{url_api_base}/repos/#{ghOrg}/#{repo}/pulls" 30 github.post url, data, (response) -> 31 msg.send "ຊ൪ʹσϓϩΠ͢ΔϓϧϦΫΤετΛ࡞ͨ͠Αʂ֬ೝͯ͠Ϛʔδͯ͠Ͷʂ" 32 msg.send response.html_url https:/ /gist.github.com/ryonext/2906f7bd9c865c2d8f1b
pull reqҰཡΛग़͢ https:/ /github.com/github/hubot- scripts/blob/master/src/scripts/ github-pulls.coffee
cron Hubotͷslack adapter Ͱ ఆظతʹൃݴ ͤ͞Δ͜ͱͰ͖Δ͕ɺbotͷൃݴʹରͯ͠bot ʹԠͤ͞Δ͜ͱͰ͖ͳ͍ʢॏཁʣ ͕ͨͬͯ͠ɺxmppΛͬͯൃݴͤ͞Δඞཁ͕ ͋Δ
xmpp xmpp Λ͏߹ɺhubot ͷslack adapterΛ͏߹ͱҧ͍ɺxmppͰૢ࡞͢ ΔͨΊͷslack accountΛ࡞͓ͬͯ͘ඞཁ͕ ͋Δ
Πϝʔδ slack adapter xmpp adapter slack account
xmpp͏߹ͷઃఆ ʢslackଆʣ
hubot x xmpp x slack
None
None
xmpp͏߹ͷઃఆ ʢhubotଆʣ ‘hubot-slack’ͷΘΓʹ’hubot-xmpp’Λ npm install͢Δ heroku ʹ্͛Δ߹ɺίϚϯυΛ `web: bin/hubot --adapter
xmpp -n {bot໊}` ʹ͢Δ
xmppิ xmppͰൃݴͨ͠༰mentionʹͳΒͳ͍ ʢॏཁʣ ͔ͤͬ͘ϨϏϡʔ௨ͯ͠ؾ͔ͮΕͳ͍ slackbot࿈ܞͤ͞ΔɻcronͰͷൃݴʹର͠ ͯslackbotʹԠͤ͞Δ
͜͏ͬͯ
͜͏ͳΔͷͰpush௨͕ དྷΔ
͓͠·͍ ࣭͋Εؾܰʹฉ͍͍ͯͩ͘͞ɻ HipChatͩͱbotؒ࿈ܞͬͱָͦ͏ͳؾ͕͠ ͯΔ