fix port extraction for node container
Build and Push Docker Images / build-and-push (push) Successful in 3m39s
Build and Push Docker Images / build-and-push (push) Successful in 3m39s
This commit is contained in:
@@ -15,6 +15,15 @@ extract_domain() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Extract SSH port from Git URL (ssh://user@host:port/path format)
|
||||
extract_port() {
|
||||
local url=$1
|
||||
|
||||
if [[ $url == ssh://* ]] && [[ $url =~ ssh://[^@]+@[^:/]+:([0-9]+) ]]; then
|
||||
echo "${BASH_REMATCH[1]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if the required environment variables are set
|
||||
if [ -z "$REPO_URL" ]; then
|
||||
echo "Error: REPO_URL environment variable must be set."
|
||||
@@ -237,15 +246,22 @@ fi
|
||||
# Ensure the SSH key has the correct permissions
|
||||
chmod 600 /root/.ssh/id_rsa
|
||||
|
||||
# Extract the domain from the REPO_URL
|
||||
# Extract the domain and port from the REPO_URL
|
||||
DOMAIN=$(extract_domain "$REPO_URL")
|
||||
PORT=$(extract_port "$REPO_URL")
|
||||
|
||||
# Add the SSH configuration for the domain
|
||||
echo "Host $DOMAIN
|
||||
HostName $DOMAIN
|
||||
IdentityFile /root/.ssh/id_rsa
|
||||
StrictHostKeyChecking no
|
||||
" >> /root/.ssh/config
|
||||
{
|
||||
echo "Host $DOMAIN"
|
||||
echo " HostName $DOMAIN"
|
||||
echo " IdentityFile /root/.ssh/id_rsa"
|
||||
echo " StrictHostKeyChecking no"
|
||||
if [ -n "$PORT" ]; then
|
||||
echo " Port $PORT"
|
||||
fi
|
||||
} >> /root/.ssh/config
|
||||
|
||||
echo "Configured SSH for $DOMAIN${PORT:+ on port $PORT}"
|
||||
|
||||
# Clone the repository if it doesn't exist
|
||||
if [ ! -d "/workspace/.git" ]; then
|
||||
|
||||
Reference in New Issue
Block a user