Last active
November 18, 2022 21:10
-
-
Save IgorDePaula/777d7d83cec26040824ca17416b072bc to your computer and use it in GitHub Desktop.
git deploy
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="/var/www/html" | |
GIT_DIR="/home/ubuntu/crm.git" | |
BRANCH="master" | |
TARGET_HOMOLOGACAO="/home/ubuntu/homologacao" | |
# GIT_DIR="/home/ubuntu/crm" | |
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