I created the following git hook to automate some tasks for me and to pipe it back down when I push a commit to my server. The code works fine when I run it directly. When the git push pushes to the server and the server executes the hook it says
remote: Deployment [BETA]: updating.
remote: git fatal not a git repository.
remote: Deployment [BETA]: complete.
remote: git fatal not a git repository.
My hook code is:
#!/usr/bin/php
<?php
chdir("/var/www");
echo "Deployment [BETA]: updating." . PHP_EOL;
exec("git pull");
echo "Deployment [BETA]: complete." . PHP_EOL;
// Get the last commit message.
$log = shell_exec("git log -n 1 HEAD");
if (stripos($log, "[trigger:composer]"))
{
echo "Composer: starting." . PHP_EOL;
system("php /home/root/bin/composer.phar update");
echo "Composer: completed." . PHP_EOL;
}
if (stripos($log, "[trigger:phpunit]"))
{
system("./vendor/bin/phpunit");
}
If anyone can help me that would be really appreciated.