Created
September 15, 2014 19:55
-
-
Save antonydevanchi/1e592b60158eee70b0a6 to your computer and use it in GitHub Desktop.
Simple deploy script
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 | |
DEPLOY_REPO="git@github.com:<user>/<rep>.git" | |
DEPLOY_BRANCH="<branch>" | |
DEPLOY_REVISION_FILE="<path>/last_revision" | |
DEPLOY_LOCAL_REPO="<path>/deploy" | |
DEPLOY_DATE_PREFIX=`date +%Y-%m-%d` | |
# Generate revision number | |
[ -r $DEPLOY_REVISION_FILE ] && REVISION=`cat $DEPLOY_REVISION_FILE` || REVISION="" | |
[ "${REVISION:0:10}" == "$DEPLOY_DATE_PREFIX" ] && CURRENT_REVISION_NUM=${REVISION:11:3} | |
CURRENT_REVISION_NUM=`echo $CURRENT_REVISION_NUM | grep -Po '[1-9]\w*$' || echo 0` | |
NUM=$[ $CURRENT_REVISION_NUM + 1 ] | |
[ ${#NUM} == "1" ] && NUM="00$NUM" | |
[ ${#NUM} == "2" ] && NUM="0$NUM" | |
NEW_REVISION=${DEPLOY_DATE_PREFIX}_${NUM} | |
# Dump number revision into file | |
echo ${NEW_REVISION} > ${DEPLOY_REVISION_FILE} | |
DEPLOY_TARGET_PATH="<path>/deploy/${NEW_REVISION}" | |
# Current revision folder | |
DEPLOY_SYMLINK="<path>/deploy/.current" | |
# Create folder | |
mkdir ${DEPLOY_TARGET_PATH} | |
# Clone Git repository | |
git clone --depth=1 ${DEPLOY_REPO} -b ${DEPLOY_BRANCH} ${DEPLOY_TARGET_PATH} && rm -rf ${DEPLOY_TARGET_PATH}/.git | |
# Something install | |
# May be deps | |
# May be databases |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment