Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute PHP from GIT post-update hook

I am using GIT on my server and I am trying to get a PHP file to be executed each time I update my repository. I'm trying to use my post-update hook to achieve this.

this is the code I tried:

#!/bin/sh

echo
echo "**** Pulling changes into Prime [Hub's post-update hook]"
echo

cd $HOME/www || exit
unset GIT_DIR
git pull hub master

exec git-update-server-info

php /path/to/directory/file.php

I can't seem to get the PHP to execute. Anyone able to shine any light on this?

like image 897
DivZero Avatar asked Sep 05 '26 11:09

DivZero


1 Answers

exec never returns. Anything you put after the exec call is dead code.

Remove the exec, or place it before your php line if that's the last thing that needs to be done. (And after doing error checking if necessary obviously.)

So for instance

...
git-update-server-info
exec php /path/to/directory/file.php

Or just simply

...
git-update-server-info
php /path/to/directory/file.php

(or move the statements around if your php script can be called before the git command.)

like image 131
Mat Avatar answered Sep 08 '26 05:09

Mat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!