Skip to content

Instantly share code, notes, and snippets.

@rubenmromero
Created August 27, 2018 13:08
Show Gist options
  • Save rubenmromero/dee3f421fd42301d06f9b8232cd0ac77 to your computer and use it in GitHub Desktop.
Save rubenmromero/dee3f421fd42301d06f9b8232cd0ac77 to your computer and use it in GitHub Desktop.
PHP :: Web service to clean and deploy a repository to which it belongs on a server through a webhook
<?php
//Deploy the current version from master branch of the project
$document_root = "<repository_root_folder>";
echo "Clean untracked files on server:";
$output = shell_exec("git clean -d --force $document_root 2>&1");
echo "<pre>$output</pre>";
echo "Revert modified files (not staged) on server...";
$output = shell_exec("git checkout -- $document_root 2>&1");
echo "<pre>$output</pre>";
echo "Pull the existent new commits from origin on server:";
$output = shell_exec("git pull 2>&1");
echo "<pre>$output</pre>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment