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
|
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
|
# Check if the required environment variables are set
|
||||||
if [ -z "$REPO_URL" ]; then
|
if [ -z "$REPO_URL" ]; then
|
||||||
echo "Error: REPO_URL environment variable must be set."
|
echo "Error: REPO_URL environment variable must be set."
|
||||||
@@ -237,15 +246,22 @@ fi
|
|||||||
# Ensure the SSH key has the correct permissions
|
# Ensure the SSH key has the correct permissions
|
||||||
chmod 600 /root/.ssh/id_rsa
|
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")
|
DOMAIN=$(extract_domain "$REPO_URL")
|
||||||
|
PORT=$(extract_port "$REPO_URL")
|
||||||
|
|
||||||
# Add the SSH configuration for the domain
|
# Add the SSH configuration for the domain
|
||||||
echo "Host $DOMAIN
|
{
|
||||||
HostName $DOMAIN
|
echo "Host $DOMAIN"
|
||||||
IdentityFile /root/.ssh/id_rsa
|
echo " HostName $DOMAIN"
|
||||||
StrictHostKeyChecking no
|
echo " IdentityFile /root/.ssh/id_rsa"
|
||||||
" >> /root/.ssh/config
|
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
|
# Clone the repository if it doesn't exist
|
||||||
if [ ! -d "/workspace/.git" ]; then
|
if [ ! -d "/workspace/.git" ]; then
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
5.0
|
5.1
|
||||||
Reference in New Issue
Block a user