Skip to content

Instantly share code, notes, and snippets.

@woodsleaf
Forked from bgallagh3r/post-recieve
Created February 21, 2019 13:39
Show Gist options
  • Select an option

  • Save woodsleaf/a756578e16487f33413187f595192a5f to your computer and use it in GitHub Desktop.

Select an option

Save woodsleaf/a756578e16487f33413187f595192a5f to your computer and use it in GitHub Desktop.
Make git run composer install/update after you push to remote server.
#!/bin/bash
DIR=$(git rev-parse --show-toplevel)
if [ -e "$DIR/composer.json" ]; then
if [ -d "$DIR/vendor" ]; then
composer.phar install
else
composer.phar update
fi
fi
@woodsleaf
Copy link
Copy Markdown
Author

touch .git/hooks/post-receive
cat < .git/hooks/post-receive
#!/bin/sh
cd ..
GIT_DIR='.git'

if [ -e "composer.json" ]; then
if [ -d "vendor" ]; then
composer install
else
composer update
fi
fi

git reset --hard
EOF
chmod +x .git/hooks/post-receive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment