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
This commit is contained in:
Elia Bieri 2023-05-03 14:00:53 +00:00
parent 96334b4eb6
commit f1ab753515
1 changed files with 6 additions and 2 deletions

View File

@ -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
fi