Created
September 17, 2013 23:04
-
-
Save jnv/6601902 to your computer and use it in GitHub Desktop.
trello2github: A hacky and awful Trello cards to GitHub Issues import.
Imports Trello color labels and cards' lists as labels, skips archived cards.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem "octokit", "~> 2.0" | |
gem "json" | |
gem "recursive-open-struct" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: | |
# - Export Trello board as JSON | |
# - Set REPO, login, and password | |
# - Run: bundle install | |
# - Run: bundle exec ./trello2github.rb my-trello-board.json | |
require 'octokit' | |
require 'recursive-open-struct' | |
require 'json' | |
REPO='my/repo' | |
client = Octokit::Client.new \ | |
login: 'username', | |
password: '' | |
def labels_names(labels) | |
labels.map(&:name).reject{ |name| name.empty? } | |
end | |
src = RecursiveOpenStruct.new(JSON.parse( IO.read(ARGV[0]) ), recurse_over_arrays: true) | |
lists = {} | |
src.lists.each do |list| | |
lists[list.id] = list.name | |
end | |
src.cards.each do |card| | |
if card.closed | |
puts "skipping closed card #{card.name}" | |
next | |
end | |
name = card.name | |
desc = card.desc | |
labels = labels_names(card.labels) | |
list = lists[card.idList] | |
opts = { | |
labels: labels + [list] | |
} | |
puts name | |
client.create_issue(REPO, name, desc, opts) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment