Last active
October 2, 2015 21:38
-
-
Save timdream/2326349 to your computer and use it in GitHub Desktop.
Minimuist pull me script that work with Github hook
This file contains 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 | |
/* host machine settings */ | |
$GIT_BIN = '/usr/local/bin/git'; | |
$LOCAL_USER = 'www'; | |
/* remote repo settings */ | |
$REMOTE = 'origin'; | |
$BRANCH = 'production'; | |
header('Content-Type: text/plain; charset=UTF-8'); | |
if (!isset($argv) && $_SERVER['REQUEST_METHOD'] !== 'POST') { | |
print <<<EOL | |
Error: Use POST request to update. | |
For testing, use 'curl -d dummy=data'. | |
EOL; | |
exit; | |
} | |
if ( trim(exec('whoami')) !== $LOCAL_USER) { | |
print 'Error: Must run as the specified user.'; | |
exit; | |
} | |
system( | |
"$GIT_BIN fetch $REMOTE 2>&1 && " . | |
"$GIT_BIN checkout -q $REMOTE/$BRANCH 2>&1 && " . | |
"$GIT_BIN submodule -q update --init 2>&1; " . | |
"$GIT_BIN log -1 2>&1" | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment