Created
August 30, 2011 09:17
-
-
Save josefadamcik/1180517 to your computer and use it in GitHub Desktop.
Revisions
-
josefadamcik renamed this gist
Aug 30, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
josefadamcik renamed this gist
Aug 30, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
josefadamcik created this gist
Aug 30, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ <?php //ftp deploy helper (git only) $targetDir = "../webdeploy"; //$lastDeploy = "bd777c31090f9e22aef12e61f7ba64c39f09f5d0"; if (isset($argv[1])) { $lastDeploy = $argv[1]; } $cfgWarning = array(); prepareDeployDir($targetDir); $files = getFileDiff($lastDeploy); printn("[deploy] copyingfiles: "); //print_r($files); foreach($files as $file) { $dir = dirname($file); $target =$targetDir . "/" . $file; $basename = basename($file); printn("\t[cp]\t" . basename($file). "\tin " . dirname($file) ); if (!file_exists($targetDir . "/" . $dir)) { mkdir ($targetDir . "/" . $dir, 0777, true); } exec("cp $file $target"); //check if we have to upload changed config files if (strpos($dir, 'config') !== false) { $cfgWarning[] = $file; } } //config deploy warning if (count($cfgWarning) > 0) { printn("[WARN] config files exported, check changes!!"); foreach ($cfgWarning as $wrnFile) { printn("\t" . $wrnFile); } } //FIXME: handle symlinks function getFileDiff($lastDeploy) { $diffOutput = array(); exec("git diff --name-only $lastDeploy HEAD", $diffOutput); return $diffOutput; } function prepareDeployDir($dir) { if (file_exists($dir)) { printn("[deploy] removing old target dir $dir"); exec("rm -rf $dir"); } mkdir($dir, 0777, true); } function printn($str = "") { print $str."\n"; }