How can I automatically deploy my app after a git push ( GitHub and node.js)?


Question

I have my application (node.js) deployed on a VPS (linux). I'm using git hub as a repository. How can I deploy the application automatically, on git push ?

1
92
2/3/2012 4:41:53 PM

Example in PHP:

Navigate to github into your github repository add click "Admin"

click tab 'Service Hooks' => 'WebHook URLs'

and add

http://your-domain-name/git_test.php

then create git_test.php

<?php 
try
{
  $payload = json_decode($_REQUEST['payload']);
}
catch(Exception $e)
{
  exit(0);
}

//log the request
file_put_contents('logs/github.txt', print_r($payload, TRUE), FILE_APPEND);


if ($payload->ref === 'refs/heads/master')
{
  // path to your site deployment script
  exec('./build.sh');
}

In the build.sh you will need to put usual commands to retrieve your site from github

63
11/13/2012 8:23:19 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon