Created
July 19, 2016 03:40
-
-
Save ibejohn818/5b393602f39576711093dcc610457992 to your computer and use it in GitHub Desktop.
Git Deploy Use-case
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
#!/usr/bin/env php | |
<?php | |
$in = fopen("php://stdin","r"); | |
$line = fgets($in); | |
preg_match_all('/(.*)( )(.*)( )(.*)/',$line,$matches); | |
if(!isset($matches[5][0])) { | |
exit; | |
} | |
$ref = $matches[5][0]; | |
$repo = preg_match_all('/^refs\/heads\/(.*)/',$ref,$matches); | |
//THE REPO NAME | |
$repo = $matches[1][0]; | |
$cwd = str_replace("/.git","",getcwd()); | |
file_put_contents("/tmp/ugh",$cwd); | |
//set the GIT_DIR env var to our working tree | |
passthru("export GIT_WORK_TREE='{$cwd}' && git checkout -f {$ref}"); | |
chdir($cwd); | |
passthru("composer install --no-dev"); | |
passthru("composer dumpautoload -o"); | |
passthru("bower install"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment