Skip to content

Instantly share code, notes, and snippets.

@ada10fl2
Last active December 13, 2020 17:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ada10fl2/9118419 to your computer and use it in GitHub Desktop.
Save ada10fl2/9118419 to your computer and use it in GitHub Desktop.
Getting PHP Git Deploy script to work on Windows
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
$l_git = "/c/Program Files (x86)/Git/bin/git";
$l_sshadd = "/c/Program Files (x86)/Git/bin/ssh-add";
$w_agent = "C:\\Program Files (x86)\\Git\\bin\\ssh-agent.exe";
$w_bash = "C:\\Program Files (x86)\\Git\\bin\\bash.exe";
$l_cmd = "'\"$l_sshadd\" /c/Users/myuser/.ssh/deploy; "
. "cd /c/xampp/htdocs; "
. "\"$l_git\" pull origin master'";
$exec = "\"$w_agent\" \"$w_bash\" -c $l_cmd 2>&1";
echo "Runnning...\n<br>";
$t0 = microtime(true);
echo "<pre>$exec</pre>";
echo shell_exec($exec);
$t = round(microtime(true) - $t0,3)*1000;
echo "<br>Done: $t ms";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment