Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Last active November 18, 2022 21:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorDePaula/777d7d83cec26040824ca17416b072bc to your computer and use it in GitHub Desktop.
Save IgorDePaula/777d7d83cec26040824ca17416b072bc to your computer and use it in GitHub Desktop.
git deploy
#!/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