Created
March 18, 2020 15:12
-
-
Save IgorDePaula/3586f0d2b1b5743d7f923bc5a520e548 to your computer and use it in GitHub Desktop.
deploy via git
This file contains 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="/var/www/html" | |
GIT_DIR="/home/ubuntu/crm.git" | |
BRANCH="master" | |
TARGET_HOMOLOGACAO="/home/ubuntu/homologacao" | |
BRANCH_HOMOLOGACAO="homologacao" | |
while read oldrev newrev ref | |
do | |
# only checking out the master (or whatever branch you would like to deploy) | |
if [ "$ref" = "refs/heads/$BRANCH" ] | |
then | |
echo "Ref $ref received. Deploying ${BRANCH} branch to production..." | |
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH | |
fi | |
if [ "$ref" = "refs/heads/$BRANCH_HOMOLOGACAO" ] | |
then | |
echo "Ref $ref received. Deploying ${BRANCH_HOMOLOGACAO} branch to homologacao..." | |
git --work-tree=$TARGET_HOMOLOGACAO --git-dir=$GIT_DIR checkout -f $BRANCH_HOMOLOGACAO | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment