This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
#!/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
|
||||
@@ -47,7 +59,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
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.0
|
||||
2.1
|
||||
@@ -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
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.0
|
||||
2.1
|
||||
Reference in New Issue
Block a user