#!/bin/bash -e STAGING_BRANCH=${STAGING_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")")")" STAGINGDIR="$ROOT/docker/4_run/staging" PROJECT_NAME="$(basename $ROOT)" if [ -e $STAGINGDIR ]; then echo "$STAGINGDIR already exists, press [ENTER] to destroy and re-install, Ctrl+C to abort." read dummy rm -rf $STAGINGDIR else echo -n "Installing into $STAGINGDIR… " echo "press [ENTER] to continue, Ctrl+C to abort." read dummy fi cd ${ROOT} mkdir -p $STAGINGDIR REMOTE_ROOT="$STAGINGDIR/$PROJECT_NAME" if [ -z "$SKIP_BRANCH_CHECK" ]; then # Check that we're on production branch. if [ $(git rev-parse --abbrev-ref HEAD) != "$STAGING_BRANCH" ]; then echo "You are NOT on the $STAGING_BRANCH branch, refusing to stage." >&2 exit 1 fi # Check that production branch has been pushed. if [ -n "$(git log origin/$STAGING_BRANCH..$STAGING_BRANCH --oneline)" ]; then echo "WARNING: not all changes to the $STAGING_BRANCH branch have been pushed." echo "Press [ENTER] to continue staging current origin/$STAGING_BRANCH, CTRL+C to abort." read dummy fi fi function find_module() { MODULE_NAME=$1 MODULE_DIR=$(python <