Skip to content

Instantly share code, notes, and snippets.

@kiasaki
Last active August 29, 2015 14:03
Show Gist options
  • Save kiasaki/00a3044d12956a828e76 to your computer and use it in GitHub Desktop.
Save kiasaki/00a3044d12956a828e76 to your computer and use it in GitHub Desktop.
post-receive hook VPS
#!/bin/sh
echo ""
echo "-----"
echo "Transfering ..."
GIT_DIR=/home/<username>/repo/<app>.git
WWW_DIR=/var/www/<app>/current
git --work-tree=$WWW_DIR --git-dir=$GIT_DIR checkout -f
echo "-----"
echo "Running composer ..."
cd $WWW_DIR
composer install
echo "-----"
echo "Fetching src ..."
cd $WWW_DIR
GIT_WORK_TREE=$WWW_DIR git --git-dir=$GIT_DIR submodule update --init --recursive
echo "-----"
echo "Setting env vars"
if [ ! -f $WWW_DIR/env.php ]; then
ln -s $WWW_DIR/../env.php $WWW_DIR/env.php
fi
echo "-----"
echo "Running migrations"
cd $WWW_DIR
php sb db:migrate
echo "-----"
echo "Clearing cache"
rm -r $WWW_DIR/../tmp/cache/*
echo "-----"
echo "Tranfered to $WWW_DIR"
echo "-----"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment