trelloのカードをgithubのissueにslackから追加する


trelloでタスク管理を行っているとそのままgithubのissueにしたい場合があったので、slackからtrelloのカードをgithub issueに追加できるようにしてみた。

npmで必要パッケージのインストール

npm install node-trello --save
npm install octonode --save

trello token 取得

github token 取得

hubot script

# Description:
#   Sample

trello = require("node-trello")
t = new trello("***", "***")
github = require('octonode')
g = github.client("***")

module.exports = (robot) ->
  robot.hear /\btrello\s+(\S+)\s+to\s+(\S+)/i, (msg) ->
    shortLink = msg.match[1]
    repository = msg.match[2]

    ghrepo = g.repo(repository)

    # shortlinkからtrelloカード情報を取得する
    t.get "/1/cards/#{shortLink}", (err, data) ->
      # カードのurlとdescriptionを追加する場合
      ghrepo.issue {title: data.name, body: "#{data.shortUrl}\n\n#{data.desc}"}, (err, body, headers) ->
        msg.reply "`#{body.title}`\n>>>\n#{body.html_url}\n```\n#{body.body}\n```"

npm package

未だ手直し予定ありですが、npmに公開した。
https://www.npmjs.com/package/hubot-trello-to-github