fetch domain from ssh url
Build and Push Docker Images / build-and-push (push) Successful in 6m50s

This commit is contained in:
Bram Kelchtermans
2024-09-11 10:46:35 +02:00
parent f2f2991b1e
commit 917e84f6ec
4 changed files with 29 additions and 4 deletions
+14 -1
View File
@@ -1,6 +1,19 @@
#!/bin/bash
set -e
extract_domain() {
local url=$1
# Handle different SSH URL formats
if [[ $url == ssh://* ]]; then
# For URLs starting with ssh://, extract the domain
echo "$url" | sed -E 's|ssh://[^@]+@([^:/]+).*|\1|'
else
# For URLs without ssh://, extract the domain after '@' and before ':'
echo "$url" | sed -E 's|[^@]+@([^:/]+).*|\1|'
fi
}
# Check if the required environment variables are set
if [ -z "$REPO_URL" ]; then
echo "Error: REPO_URL environment variable must be set."
@@ -27,7 +40,7 @@ fi
chmod 600 /root/.ssh/id_rsa
# Extract the domain from the REPO_URL
DOMAIN=$(echo $REPO_URL | awk -F'[@:]' '{print $3}')
DOMAIN=extract_domain "$REPO_URL"
# Check if the repository directory already exists
if [ ! -d "/workspace/.git" ]; then