Guest User

Untitled

a guest
Dec 11th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. include("ringo/subprocess");
  2.  
  3. var log = require("ringo/logging").getLogger(module.id);
  4.  
  5. exports.app = function(req) {
  6.  
  7. log.info("Incoming request.");
  8.  
  9. if (req.method !== "POST") {
  10. log.info("Not a valid POST request.");
  11. return {
  12. status: 400,
  13. headers: {"Content-Type": "text/plain"},
  14. body: ["Bad request!"]
  15. };
  16. }
  17.  
  18. if (req.pathInfo !== "/github-update-somesupersecretURIsuffix") {
  19. log.info("Invalid update request. " + req.pathInfo);
  20. return {
  21. status: 403,
  22. headers: {"Content-Type": "text/plain"},
  23. body: ["Forbidden!"]
  24. };
  25. }
  26.  
  27. var str = command("/path/to/scripts/github-pull.sh");
  28.  
  29. log.info("Updated repository ==> " + str);
  30.  
  31. return {
  32. status: 200,
  33. headers: {"Content-Type": "text/plain"},
  34. body: ["Done."]
  35. };
  36. };
  37.  
  38. if (require.main == module)
  39. require("ringo/httpserver").main(module.id);
Add Comment
Please, Sign In to add comment