fix(deploy): improve SSH key handling and add debug output
Deploy to route.crispygoat.com / deploy (push) Successful in 3m23s
Deploy to route.crispygoat.com / deploy (push) Successful in 3m23s
This commit is contained in:
@@ -109,20 +109,28 @@ jobs:
|
|||||||
set -e
|
set -e
|
||||||
APP_DIR=/home/tyler/route-commerce
|
APP_DIR=/home/tyler/route-commerce
|
||||||
|
|
||||||
# Setup SSH key (secret contains multiline private key)
|
# Setup SSH key - write raw (no printf which can corrupt multi-line keys)
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
printf '%s\n' "$SERVER_SSH_KEY" > ~/.ssh/id_ed25519
|
echo "$SERVER_SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
|
||||||
|
# Verify key was written correctly
|
||||||
|
if ! grep -q "PRIVATE KEY" ~/.ssh/id_ed25519; then
|
||||||
|
echo "ERROR: SSH key not found or malformed. Check SERVER_SSH_KEY secret."
|
||||||
|
cat ~/.ssh/id_ed25519 || echo "File is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
ssh-keyscan -H route.crispygoat.com >> ~/.ssh/known_hosts 2>/dev/null || true
|
ssh-keyscan -H route.crispygoat.com >> ~/.ssh/known_hosts 2>/dev/null || true
|
||||||
|
|
||||||
# Test SSH connection
|
# Test SSH connection with verbose output for debugging
|
||||||
echo "Testing SSH connection..."
|
echo "Testing SSH connection..."
|
||||||
ssh -o ConnectTimeout=15 -o StrictHostKeyChecking=no tyler@route.crispygoat.com "echo 'SSH OK' && hostname" || { echo "SSH FAILED - check SERVER_SSH_KEY secret"; exit 1; }
|
ssh -o ConnectTimeout=15 -o StrictHostKeyChecking=no -o LogLevel=VERBOSE tyler@route.crispygoat.com "echo 'SSH OK' && hostname" 2>&1 || { echo "SSH FAILED"; exit 1; }
|
||||||
|
|
||||||
# Create app dir on server
|
# Create app dir on server
|
||||||
ssh tyler@route.crispygoat.com "mkdir -p $APP_DIR/.next $APP_DIR/public"
|
ssh tyler@route.crispygoat.com "mkdir -p $APP_DIR/.next $APP_DIR/public"
|
||||||
|
|
||||||
# Write production env file using printf (avoids heredoc quoting issues)
|
# Write production env file
|
||||||
ENV_FILE=$(mktemp)
|
ENV_FILE=$(mktemp)
|
||||||
{
|
{
|
||||||
printf 'DATABASE_URL=%s\n' "$DATABASE_URL"
|
printf 'DATABASE_URL=%s\n' "$DATABASE_URL"
|
||||||
|
|||||||
Reference in New Issue
Block a user