Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hubot事例

Avatar for ryonext ryonext
January 21, 2015

 Hubot事例

弊社のHubotとSlack連携の活用事例です。

Avatar for ryonext

ryonext

January 21, 2015
Tweet

More Decks by ryonext

Other Decks in Technology

Transcript

  1. develop ͔Β master΁ ͷ pull request Λ࡞Δ ඞཁͳαʔϏε Circle CI

    ΋ͪΖΜ J但 Ͱ΋͍͚Δ masterʹϚʔδ͞ΕͨΒ ͦͷ··ຊ൪σϓϩ Π·Ͱ૸ΔΑ͏ʹͯ͠Δલఏ
  2. 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 ͱ૊Έ߹Θͤͯ࢖͏΂͖
  3. cronࣄྫ1 pull requestͷ௨஌ ຖ೔ܾ·ͬͨ࣌ؒʹͳͬͨΒ hubot show org-pulls Λ࣮ߦ͠ɺpull request ҰཡΛ

    ग़͢ ຖ೔ܾ·ͬͨ࣌ؒʹ࢒͍ͬͯΔpull requestΛදࣔ͢Δ͜ͱʹΑΓɺϨϏϡʔ͕ଅਐ͞Εੜ࢈ੑͷ޲ ্ʹͭͳ͕Δ
  4. 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