-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jamie Forrest
committed
May 22, 2012
0 parents
commit f0e2de5
Showing
6 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
|
||
pids | ||
logs | ||
results | ||
|
||
node_modules | ||
npm-debug.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: node app.js |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
github-asana | ||
============ | ||
|
||
github-asana is a little web server written in node.js that integrates GitHub with Asana (the project management app). | ||
The server listens for GitHub Post-Receive Hooks, and sends commit messages as comments in Asana Tasks. | ||
|
||
http://asana.com/ | ||
|
||
Installation | ||
============ | ||
To get it up and running, open up the lib/github-asana.js file and update the asana_key variable with your Asana API key. | ||
Then host the app somewhere (heroku is easiest) and provide the url to the app in the "Service Hooks / WebHook URLs" section of the GitHub repository you want to integrate with Asana (the app receives GitHub's POST requests at the base url or '/'). | ||
|
||
Commit Syntax | ||
============= | ||
For now, the only thing supported is referencing Asana task IDs in your commit messages (prefixed by a #). When you commit, write something like: | ||
|
||
git commit -m "fixed bug #123456789" | ||
|
||
That will send the commit message to Asana and place it as a comment in the task with ID 123456789. | ||
Task IDs in Asana are the strings of digits after the final slash in the url, visible when you're viewigin a task. | ||
|
||
Roadmap | ||
======= | ||
In the future, we will be adding the ability to assign tasks and add tags to tasks, with syntax such as: | ||
|
||
git commit -m "fixed bug #123456789 to:user@example.com tags:'in progress','feedback'" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var express = require('express') | ||
, github_asana = require('./lib/github-asana'); | ||
|
||
var app = module.exports = express.createServer(); | ||
|
||
// Configuration | ||
|
||
app.configure(function(){ | ||
app.use(express.bodyParser()); | ||
app.use(express.methodOverride()); | ||
app.use(app.router); | ||
}); | ||
|
||
app.configure('development', function(){ | ||
app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); | ||
}); | ||
|
||
app.configure('production', function(){ | ||
app.use(express.errorHandler()); | ||
}); | ||
|
||
// Routes | ||
|
||
app.post('/', github_asana.index); | ||
|
||
var port = process.env.PORT || 3000; | ||
app.listen(port, function() { | ||
console.log("Listening on " + port); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var util = require('util'); | ||
var request = require('request'); | ||
var asana_key = "your-asana-api-key"; | ||
var asana_base_url = 'https://app.asana.com/api/1.0'; | ||
|
||
function getTaskComments(req) { | ||
var payload; | ||
if (typeof req.body.payload === 'object') { | ||
payload = req.body.payload; | ||
} else { | ||
payload = JSON.parse(req.body.payload); | ||
} | ||
var commits = payload.commits; | ||
var comments = []; | ||
for (var i in commits) { | ||
var regex = /#(\d+)\b/g; | ||
var tasks = commits[i].message.match(/#(\d+)\b/g); | ||
if (tasks) { | ||
for (var j in tasks) { | ||
comments.push({ | ||
"id":tasks[j].slice(1), | ||
"text":commits[i].author.username + ' referenced this issue from a commit\n'+commits[i].id.slice(0,7)+' '+commits[i].message+'\n'+commits[i].url | ||
}); | ||
} | ||
} | ||
} | ||
return comments; | ||
} | ||
|
||
function updateAsana(taskComments) { | ||
var auth = 'Basic ' + new Buffer(asana_key+":").toString('base64'); | ||
for (var i in taskComments) { | ||
request.post({ | ||
url: asana_base_url+"/tasks/"+taskComments[i].id+"/stories", | ||
json: {data: {text:taskComments[i].text}}, | ||
headers: {"Authorization":auth} | ||
}, | ||
function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
console.log(body) | ||
} else { | ||
console.log(response.statusCode+': '+error); | ||
console.log(util.inspect(response.body)); | ||
} | ||
}) | ||
} | ||
} | ||
|
||
exports.index = function(req, res){ | ||
updateAsana(getTaskComments(req)); | ||
res.send("Updated Asana."); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "github-asana" | ||
, "version": "0.0.1" | ||
, "private": false | ||
, "dependencies": { | ||
"express": "2.5.8" | ||
, "jade": ">= 0.0.1" | ||
, "request": ">= 2.9.202" | ||
} | ||
} |