Skip to content

Commit

Permalink
Added the deploy hookin
Browse files Browse the repository at this point in the history
zanker committed Apr 10, 2012
1 parent def3a58 commit 6baad62
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/github-trello/http.rb
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@ def add_comment(card_id, comment)
http_request(:post, "/1/cards/#{card_id}/actions/comments", :body => "text=#{CGI::escape(comment)}")
end

def get_cards(list_id)
http_request(:get, "/1/lists/#{list_id}/cards", :params => {:fields => "idList"})
end

private
def http_request(method, request_path, args={})
request_path << "?"
29 changes: 28 additions & 1 deletion lib/github-trello/server.rb
Original file line number Diff line number Diff line change
@@ -71,8 +71,35 @@ class Server < Sinatra::Base
""
end

post "/deployed/:repo" do
config, http = self.class.config, self.class.http
if !config["on_deploy"]
raise "Deploy triggered without a on_deploy config specified"
elsif !config["on_close"] or !config["on_close"]["move_to"]
raise "Deploy triggered and either on_close config missed or move_to is not set"
end

update_config = config["on_deploy"]

to_update = {}
if update_config["move_to"] and update_config["move_to"][params[:repo]]
to_update[:idList] = update_config["move_to"][params[:repo]]
end

if update_config["archive"]
to_update[:closed] = true
end

cards = JSON.parse(http.get_cards(config["on_close"]["move_to"]))
cards.each do |card|
http.update_card(card["id"], to_update)
end

""
end

get "/" do
" "
""
end

def self.config=(config)

0 comments on commit 6baad62

Please sign in to comment.