Last active
June 10, 2016 05:35
-
-
Save balintsera/7522a669345a574cbcc1f22e300cdcd1 to your computer and use it in GitHub Desktop.
A dead simple php deploy script for git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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