Last active
May 25, 2016 18:51
-
-
Save JSONOrona/f3517b1f349119bd882c53e718493618 to your computer and use it in GitHub Desktop.
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 | |
# set -x | |
REPO='v3' | |
USER='bitrix' | |
# Dir paths on remote server | |
# These are associated with branches within a git project | |
DEV_BRANCH='dev0' | |
DEV="${USER}@${DEV_BRANCH}.4lph40m3g4.com:/home/${DEV_BRANCH}" | |
if ! [ -t 0 ]; then | |
read -a ref | |
fi | |
# Get branch name from ref head | |
IFS='/' read -ra REF <<< "${ref}" | |
branch="${REF[2]}" | |
# Make tmp dir for extracting files and cleaning up .git (we dont want them on the live site) | |
tmpdir="/tmp/$REPO/$branch" | |
mkdir -p $tmpdir | |
# Assuming git is installed at /home/git/... | |
git --work-tree=$tmpdir --git-dir="/var/opt/gitlab/git-data/repositories/ezpz/$REPO.git" checkout -f $branch | |
# If pushing to DEV_BRANCH, deploy on DEV | |
if [ "$DEV_BRANCH" == "$branch" ]; then | |
# test | |
#echo "Do rsync... $branch" | |
rsync -avzre ssh --delete "$tmpdir/" $DEV | |
fi | |
# If pushing to STAGE_BRANCH, deploy on STAGE | |
#if [ "$STAGE_BRANCH" == "$branch" ]; then | |
#rsync -vzre ssh --delete "$tmpdir/" $STAGE | |
#fi | |
rm -rf "/tmp/$REPO" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment