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 ?
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