Forked from roalcantara/import_issues_from_github_to_taiga.ruby
Created
December 19, 2017 09:53
-
-
Save canabady/6c0612009681ff36b4cc1d24ff519405 to your computer and use it in GitHub Desktop.
Importing issues from github to taiga via API
This file contains hidden or 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
require 'json' | |
require 'rest-client' | |
puts 'Creating User Stories from github issutes.. STARTED!' | |
#getting github's token: https://help.github.com/articles/creating-an-access-token-for-command-line-use | |
github_token = "token foo" | |
#github params | |
github = {:url => 'https://api.github.com/repos/foo/foo/issues', :token => github_token} | |
#Getting taiga's token: | |
taiga_username = 'foo' | |
taiga_password = 'foo' | |
auth = RestClient.post 'https://api.taiga.io/api/v1/auth', {:type => 'normal', :username => taiga_username, :password => taiga_password}.to_json, :content_type => :json | |
taiga_token = JSON.parse(auth)['auth_token'] | |
#replace with the taiga project id | |
taiga_project_id = 00001 | |
#taiga params | |
taiga = {:url => 'https://api.taiga.io/api/v1/userstories', :token => "Bearer #{taiga_token}", :project_id => taiga_project_id} | |
puts 'Loading Issues from Github..' | |
response = RestClient::Request.execute(method: :get, url: github[:url], | |
timeout: 10, headers: {params: {Authorization: github[:token]}}) | |
puts "Issues loaded: #{response}" | |
puts "Converting request to JSON.." | |
json = JSON.parse(response) | |
puts "Creating User Stories on Taiga.." | |
json.each do |issue| | |
puts "Creating User Story on Taiga with subject: #{issue['title']} and description: #{issue['body']}" | |
RestClient.post taiga[:url], {:project => taiga[:project_id], :subject => issue['title'], :description => issue['body'], :external_reference => [:github, issue['html_url']],}.to_json, {:content_type => :json, :Authorization => taiga[:token]} | |
end | |
puts "OK!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment