fix(ci): add SSH connect timeout and host discovery fallback to deploy workflow
All checks were successful
Deploy Docmost Wiki / Deploy to cisystem (push) Successful in 26s
All checks were successful
Deploy Docmost Wiki / Deploy to cisystem (push) Successful in 26s
This commit is contained in:
parent
8de2c0b2bb
commit
90ce89fb30
1 changed files with 24 additions and 5 deletions
|
|
@ -29,18 +29,37 @@ jobs:
|
||||||
echo "$SSH_KEY" > ~/.ssh/id_rsa
|
echo "$SSH_KEY" > ~/.ssh/id_rsa
|
||||||
chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
|
||||||
TARGET_HOST="${REMOTE_HOST:-16.113.106.152}"
|
|
||||||
TARGET_USER="${REMOTE_USER:-ubuntu}"
|
TARGET_USER="${REMOTE_USER:-ubuntu}"
|
||||||
|
DEFAULT_GATEWAY=$(ip route 2>/dev/null | awk '/default/ {print $3}' || true)
|
||||||
|
|
||||||
|
SSH_OPTS="-o StrictHostKeyChecking=no -o ConnectTimeout=5 -i ~/.ssh/id_rsa"
|
||||||
|
|
||||||
|
TARGET_HOST=""
|
||||||
|
for H in "${REMOTE_HOST}" "16.113.106.152" "$DEFAULT_GATEWAY" "172.17.0.1" "host.docker.internal"; do
|
||||||
|
if [ -n "$H" ]; then
|
||||||
|
echo "Testing SSH connection to $H..."
|
||||||
|
if ssh $SSH_OPTS "$TARGET_USER@$H" "echo connection_ok" 2>/dev/null | grep -q "connection_ok"; then
|
||||||
|
TARGET_HOST="$H"
|
||||||
|
echo "Successfully connected to target host: $TARGET_HOST"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$TARGET_HOST" ]; then
|
||||||
|
echo "Error: Unable to connect via SSH to any target host candidate."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Create target directories
|
# Create target directories
|
||||||
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa $TARGET_USER@$TARGET_HOST "mkdir -p /home/ubuntu/docmost/patches"
|
ssh $SSH_OPTS $TARGET_USER@$TARGET_HOST "mkdir -p /home/ubuntu/docmost/patches"
|
||||||
|
|
||||||
# Copy compose configuration and patches
|
# Copy compose configuration and patches
|
||||||
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa docker-compose.yml $TARGET_USER@$TARGET_HOST:/home/ubuntu/docmost/docker-compose.yml
|
scp $SSH_OPTS docker-compose.yml $TARGET_USER@$TARGET_HOST:/home/ubuntu/docmost/docker-compose.yml
|
||||||
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa patches/* $TARGET_USER@$TARGET_HOST:/home/ubuntu/docmost/patches/
|
scp $SSH_OPTS patches/* $TARGET_USER@$TARGET_HOST:/home/ubuntu/docmost/patches/
|
||||||
|
|
||||||
# Restart containers cleanly
|
# Restart containers cleanly
|
||||||
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa $TARGET_USER@$TARGET_HOST 'bash -s' << 'EOF'
|
ssh $SSH_OPTS $TARGET_USER@$TARGET_HOST 'bash -s' << 'EOF'
|
||||||
set -e
|
set -e
|
||||||
cd /home/ubuntu/docmost
|
cd /home/ubuntu/docmost
|
||||||
docker compose pull docmost redis
|
docker compose pull docmost redis
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue