Created
May 3, 2018 21:20
-
-
Save thomasweng15/6726f99cee79cf0adc037c6ba85c511d to your computer and use it in GitHub Desktop.
Git deploy post-receive hook
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 | |
TARGET="/home/thomas_weng11/deploy-robopubs" | |
GIT_DIR="/home/thomas_weng11/robopubs.git" | |
BRANCH="master" | |
while read oldrev newrev ref | |
do | |
# only checking out the branch to deploy | |
if [[ $ref = refs/heads/"$BRANCH" ]]; | |
then | |
echo "Ref $ref received. Deploying ${BRANCH} branch to prod..." | |
git --work-tree="$TARGET" --git-dir="$GIT_DIR" checkout -f | |
source /home/thomas_weng11/deploy-robopubs/robopubsenv/bin/activate | |
pip install -r /home/thomas_weng11/deploy-robopubs/requirements.txt | |
deactivate | |
sudo systemctl reload-or-restart myproject.service | |
else | |
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment