From f1ab753515c1c0d64f6ee141a80fadbdc15ca144 Mon Sep 17 00:00:00 2001 From: Elia Bieri Date: Wed, 3 May 2023 14:00:53 +0000 Subject: [PATCH] Merged in bugfix/caprover-------------- (pull request #68) Fix double-hyphen bug * Fix double-hyphen bug * Update regex for replacing dashes * Make dash logic above Approved-by: Daniel Egger --- caprover_deploy.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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