diff --git a/caprover_deploy.sh b/caprover_deploy.sh index 1c16b30f..23a89760 100755 --- a/caprover_deploy.sh +++ b/caprover_deploy.sh @@ -16,13 +16,17 @@ echo "$BRANCH_NAME_SLUG" DEFAULT_APP_NAME="vbv-$BRANCH_NAME_SLUG" APP_NAME=${1:-$DEFAULT_APP_NAME} +# remove multiple dashes and make sure it does not end with a dash +APP_NAME=$(echo "$APP_NAME" | sed -E 's/-+/-/g') +APP_NAME=$(echo "$APP_NAME" | sed 's/-\+$//') + # shorten APP_NAME to 32 characters # app names with more character seem to fail in some steps in CapRover # CapRover generates longer names out from the app name and there # seems to be a limit in Docker of 64 characters if (( ${#APP_NAME} > 32 )); then hash="$(echo -n "$APP_NAME" | md5sum | cut -c1-4)" - APP_NAME="$(echo -n "${APP_NAME:0:28}-${hash}")" + APP_NAME=$(echo -n "${APP_NAME:0:28}-${hash}") fi echo "Deploy to $APP_NAME" @@ -69,4 +73,4 @@ if [ -n "$CI" ]; then echo "Running within Bitbucket Pipelines" export CAPROVER_APP_URL="$APP_URL" echo "https://$CAPROVER_APP_URL" > /tmp/caprover_app_url.txt -fi \ No newline at end of file +fi