-
-
Save ginader/3494768 to your computer and use it in GitHub Desktop.
Github pull request server
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
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); |
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
#!/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