Skip to content

Instantly share code, notes, and snippets.

@botic
Created August 27, 2012 12:59
Show Gist options
  • Save botic/3488230 to your computer and use it in GitHub Desktop.
Save botic/3488230 to your computer and use it in GitHub Desktop.
Github pull request server
include("ringo/subprocess");
var log = require("ringo/logging").getLogger(module.id);
exports.app = function(req) {
log.info("Incoming request.");
if (req.method !== "POST") {
log.info("Not a valid POST request.");
return {
status: 400,
headers: {"Content-Type": "text/plain"},
body: ["Bad request!"]
};
}
if (req.pathInfo !== "/github-update-somesupersecretURIsuffix") {
log.info("Invalid update request. " + req.pathInfo);
return {
status: 403,
headers: {"Content-Type": "text/plain"},
body: ["Forbidden!"]
};
}
var str = command("/path/to/scripts/github-pull.sh");
log.info("Updated repository ==> " + str);
return {
status: 200,
headers: {"Content-Type": "text/plain"},
body: ["Done."]
};
};
if (require.main == module)
require("ringo/httpserver").main(module.id);
#!/bin/sh
cd /path/to/repository/to/update/
git pull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment