Skip to content

Instantly share code, notes, and snippets.

@balintsera
Last active June 10, 2016 05:35
Show Gist options
  • Save balintsera/7522a669345a574cbcc1f22e300cdcd1 to your computer and use it in GitHub Desktop.
Save balintsera/7522a669345a574cbcc1f22e300cdcd1 to your computer and use it in GitHub Desktop.
A dead simple php deploy script for git
<?php
header("Content-Type: text/plain", true, 200);
echo "Deploying...\n";
$projectRoot = __DIR__;
chdir($projectRoot);
// A user must be set up who can write the docroot
if (empty(getenv('DEPLOY_USER'))) {
echo 'no user set';
}
$deployUser = getenv('DEPLOY_USER');
// Run deploy
$cleanPull = '(sudo -u '. $deployUser . ' -S git reset --hard HEAD && sudo -u ' . $deployUser . ' -S git pull ) 2>&1';
exec($cleanPull, $out, $result);
// Show the results
echo "Exit code was: " . $result . "\n" . "Results:\n" . implode("\n", $out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment