LoginSignup
22
23

More than 5 years have passed since last update.

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

Last updated at Posted at 2015-04-03

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

22
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
23