#!/bin/bash -e DEPLOY_BRANCH=${DEPLOY_BRANCH:-production} # macOS does not support readlink -f, so we use greadlink instead if [[ `uname` == 'Darwin' ]]; then command -v greadlink 2>/dev/null 2>&1 || { echo >&2 "Install greadlink using brew."; exit 1; } readlink='greadlink' else readlink='readlink' fi ROOT="$(dirname "$(dirname "$($readlink -f "$0")")")" DEPLOYDIR="$ROOT/docker/4_run/deploy" PROJECT_NAME="$(basename $ROOT)" if [ -e $DEPLOYDIR ]; then echo "$DEPLOYDIR already exists, press [ENTER] to DESTROY AND DEPLOY, Ctrl+C to abort." read dummy rm -rf $DEPLOYDIR else echo -n "Deploying to $DEPLOYDIR… " echo "press [ENTER] to continue, Ctrl+C to abort." read dummy fi cd ${ROOT} mkdir -p $DEPLOYDIR REMOTE_ROOT="$DEPLOYDIR/$PROJECT_NAME" if [ -z "$SKIP_BRANCH_CHECK" ]; then # Check that we're on production branch. if [ $(git rev-parse --abbrev-ref HEAD) != "$DEPLOY_BRANCH" ]; then echo "You are NOT on the $DEPLOY_BRANCH branch, refusing to deploy." >&2 exit 1 fi # Check that production branch has been pushed. if [ -n "$(git log origin/$DEPLOY_BRANCH..$DEPLOY_BRANCH --oneline)" ]; then echo "WARNING: not all changes to the $DEPLOY_BRANCH branch have been pushed." echo "Press [ENTER] to continue deploying current origin/$DEPLOY_BRANCH, CTRL+C to abort." read dummy fi fi function find_module() { MODULE_NAME=$1 MODULE_DIR=$(python <