Created
June 14, 2016 09:21
-
-
Save SuryaElite/c83d55557afcc1812ec9c6fef6a56571 to your computer and use it in GitHub Desktop.
Deploy Code via Bash Git Hub
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 | |
# 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