Skip to content

Instantly share code, notes, and snippets.

@SuryaElite
Created June 14, 2016 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SuryaElite/c83d55557afcc1812ec9c6fef6a56571 to your computer and use it in GitHub Desktop.
Save SuryaElite/c83d55557afcc1812ec9c6fef6a56571 to your computer and use it in GitHub Desktop.
Deploy Code via Bash Git Hub
#!/bin/bash
# App Vars
GIT_DIR='~/user/code'
GIT_BRANCH='integration'
USER=`whoami`
GIT=`which git`
# Go to the Git Directory
cd $GIT_DIR
echo -e "[$(date +'%m-%d-%Y %T')] ${USER} pulling the code from Git."
#checkout to the branch & pull the code
branch=`$GIT checkout $GIT_BRANCH`
result=`$GIT pull`
# Check if new code comes after
if [ "$result" == "Already up-to-date." ]; then
echo "[$(date +'%m-%d-%Y %T')] No Deployments. Code is already up-to-date."
else
echo "[$(date +'%m-%d-%Y %T')] ${result} \n"
rsync -au $GIT_DIR /var/www/project
echo "[$(date +'%m-%d-%Y %T')] Deployment done \n"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment