Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base: 4ced5b2ae0
...
compare: 4a41df0ed6
  • 5 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 40 additions and 16 deletions.
  1. +24 −0 README.md
  2. +1 −1  bin/trello-web
  3. +15 −15 lib/github-trello/server.rb
24 README.md
View
@@ -2,3 +2,27 @@ Overview
===
Allows you to manage or reference your Trello board through commits to Github. Tag a commit with "Closes 1234" to have a card automatically archived, or "Card 1234" to have the commit sent to the card.
+Commands
+-
+Commit messages are searched for `(case|card|close|archive|fix)e?s? \D?([0-9]+)` to find the card short id. Case/card resolve to on_start configuration, close/fix resolve to on_close, and archive will just archive the card regardless.
+
+The commit message is added as a comment to the card as well.
+
+Usage
+-
+
+See `trello-web --help` for a list of arguments for starting the server. If your domain name is foobar.com and the server is listening on port 4000, then set the posthook URL on Github to __http://foobar.com:4000/posthook__
+
+On the first run, it will create an empty configuration file for you that you will need to configure based on how you want it to manage.
+
+You will need to get your api key and OAuth token with read/write access that won't expire for this to work. You can either use your own account, or create a separate deployment one for this.
+
+Go to https://trello.com/1/appKey/generate to get your key, then go to _https://trello.com/1/authorize?response_type=token&name=Trello+Github+Integration&scope=read,write&expiration=never&key=[Your Key Here]_ replacing __[Your Key Here]__ with the key Trello gave you. Authorize the request and then add the token and key to your trello.yml file.
+
+You can get the board id from the URL, for example https://trello.com/board/trello-development/4d5ea62fd76aa1136000000c the board id is _4d5ea62fd76aa1136000000ca_.
+
+There are 3 actions you can configure to decide what happens to a card. Currently due to a bug in Trello's API, you cannot move a card to another list through the API, so only __archive__ will work. The code is already in, just waiting on Trello to fix the bug.
+
+To do
+-
+Once Trello fixes the list API bug, I'll be implementing an on deploy action for people who want to be able to move cards from list A to B, such as moving from a "Pending Deployment" to "Live" or just archiving the cards.
2  bin/trello-web
View
@@ -14,7 +14,7 @@ Vegas::Runner.new(GithubTrello::Server, "trello-web", {
puts "We've generated an example one for you, but you need to configure it still."
File.open(path, "w+") do |f|
- f.write("#board_ids:\n# [repo name]: [board id]\n#oauth_token: [token]\n#api_key: [key]#on_start:\n# move_to: [list id]\n#on_close:\n# move_to: [list id]\n# archive: false\n# on_deploy:\n# move_to: [list id]\n# archive: true")
+ f.write("# NOTE: Due to a Trello API bug, currently only archive is supported and not move_to.\n\nboard_ids:\n [repo name]: [board id]\noauth_token: [token]\napi_key: [key]\non_start:\n move_to: [list id]\non_close:\n move_to: [list id]\n archive: false\non_deploy:\n move_to: [list id]\n archive: true")
end
exit
30 lib/github-trello/server.rb
View
@@ -5,7 +5,7 @@
module GithubTrello
class Server < Sinatra::Base
- get "/posthook" do
+ post "/posthook" do
config, http = self.class.config, self.class.http
payload = JSON.parse(params[:payload])
@@ -28,17 +28,6 @@ class Server < Sinatra::Base
match = commit["message"].match(/((case|card|close|archive|fix)e?s? \D?([0-9]+))/i)
next unless match and match[3].to_i > 0
- # Determine the action to take
- update_config = case match[2].downcase
- when "case", "card" then config["on_start"]
- when "close", "fix" then config["on_close"]
- when "archive" then {:archive => true}
- end
-
- unless update_config.is_a?(Hash)
- raise "Updating card with #{match[2].downcase} type, but no config found to indicate what to do"
- end
-
results = http.get_card(board_id, match[3].to_i)
unless results
puts "[ERROR] Cannot find card matching ID #{match[3]}"
@@ -54,11 +43,22 @@ class Server < Sinatra::Base
http.add_comment(results["id"], message)
+ # Determine the action to take
+ update_config = case match[2].downcase
+ when "case", "card" then config["on_start"]
+ when "close", "fix" then config["on_close"]
+ when "archive" then {:archive => true}
+ end
+
+ next unless update_config.is_a?(Hash)
+
# Modify it if needed
to_update = {}
- unless results["idList"] == update_config["move_to"]
- to_update[:idList] = update_config["move_to"]
- end
+
+ # Disabled for now due to a Trello bug
+ #unless results["idList"] == update_config["move_to"]
+ # to_update[:idList] = update_config["move_to"]
+ #end
if !results["closed"] and update_config["archive"]
to_update[:closed] = true

No commit comments for this range

Something went wrong with that request. Please try again.