Last active
June 2, 2018 11:11
-
-
Save lorne-luo/24b7ab941cc14e3c4fe5a07881c64cae to your computer and use it in GitHub Desktop.
Git hooks for deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read oldrev newrev refname | |
do | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
if [ "master" == "$branch" ]; then | |
sudo git --git-dir=/home/git/ozsales.git --work-tree=/opt/ozsales checkout -f master >/dev/null | |
cd /opt/ozsales | |
PIP=${HOME}/venv/ozsales/bin/pip | |
PYTHON=${HOME}/venv/ozsales/bin/python | |
sudo -u ozsales ${PIP} install -r requirements.pip || exit 1 | |
sudo chown ozsales ${HOME}/venv/ozsales -R | |
sudo -u ozsales ${PYTHON} manage.py migrate | |
sudo -u ozsales ${PYTHON} manage.py js_reverse | |
sudo -u ozsales gulp build | |
sudo -u ozsales ${PYTHON} manage.py collectstatic --noinput | |
sudo supervisorctl restart ozsales | |
sudo supervisorctl restart ozsales_celery | |
fi | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
umask 002 | |
PROJECT=ozsales | |
git --git-dir=/home/git/${PROJECT}.git --work-tree=/opt/${PROJECT} diff --name-status -w | grep ^M | |
if [ $? -eq 0 ]; then | |
echo " | |
********************************** | |
** LOCAL MODIFICATIONS DETECTED ** | |
********************************** | |
Please fix and try again." | |
exit 127 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment