Remove ssh debug, add rsync
This commit is contained in:
@ -10,7 +10,7 @@ on:
|
||||
- 'css/**'
|
||||
- 'js/**'
|
||||
- 'images/**'
|
||||
workflow_dispatch:
|
||||
workflow_dispatch: # Now available in 1.24.2!
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
@ -27,70 +27,33 @@ jobs:
|
||||
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
echo "🔧 Setting up SSH configuration..."
|
||||
mkdir -p ~/.ssh
|
||||
|
||||
# Debug: Check if secret exists and has content
|
||||
if [ -z "${{ secrets.DEPLOY_SSH_KEY }}" ]; then
|
||||
echo "❌ DEPLOY_SSH_KEY secret is empty or not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ SSH key secret found"
|
||||
|
||||
# Write the private key
|
||||
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
|
||||
# Debug: Verify key file was created
|
||||
if [ ! -f ~/.ssh/deploy_key ]; then
|
||||
echo "❌ Failed to create SSH key file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ SSH key file created"
|
||||
|
||||
# Verify key format
|
||||
if ! ssh-keygen -l -f ~/.ssh/deploy_key; then
|
||||
echo "❌ SSH key appears to be malformed"
|
||||
echo "Key file contents (first few lines):"
|
||||
head -3 ~/.ssh/deploy_key
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ SSH key format is valid"
|
||||
|
||||
# Set server IP and scan for host keys
|
||||
SERVER_IP="192.168.4.56"
|
||||
echo "🔍 Scanning for SSH host keys on $SERVER_IP..."
|
||||
|
||||
# Add error handling for ssh-keyscan
|
||||
if ! ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts 2>/dev/null; then
|
||||
echo "❌ Failed to get SSH host keys from $SERVER_IP"
|
||||
echo "Trying alternative approach..."
|
||||
ssh-keyscan $SERVER_IP >> ~/.ssh/known_hosts 2>/dev/null || {
|
||||
echo "⚠️ ssh-keyscan failed, adding StrictHostKeyChecking=no to SSH commands"
|
||||
}
|
||||
else
|
||||
echo "✅ SSH host keys retrieved successfully"
|
||||
fi
|
||||
|
||||
echo "✅ SSH setup completed"
|
||||
# Use relaxed host checking
|
||||
echo "Host *" > ~/.ssh/config
|
||||
echo " StrictHostKeyChecking no" >> ~/.ssh/config
|
||||
echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config
|
||||
chmod 600 ~/.ssh/config
|
||||
|
||||
- name: Deploy website
|
||||
run: |
|
||||
# Server configuration
|
||||
SERVER_IP="192.168.4.56" # Your server IP
|
||||
DEPLOY_USER="deploy" # The user we just created
|
||||
# Install rsync
|
||||
echo "📦 Installing rsync..."
|
||||
apt-get update && apt-get install -y rsync
|
||||
|
||||
SERVER_IP="192.168.4.56"
|
||||
DEPLOY_USER="deploy"
|
||||
WEBSITE_DIR="/media/stephen/Storage_Linux/infrastructure/services/websites/maverickApplications"
|
||||
|
||||
echo "📁 Syncing files to server..."
|
||||
rsync -avz --delete \
|
||||
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
|
||||
-e "ssh -i ~/.ssh/deploy_key" \
|
||||
./ $DEPLOY_USER@$SERVER_IP:$WEBSITE_DIR/
|
||||
|
||||
echo "🔄 Restarting website container..."
|
||||
ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no $DEPLOY_USER@$SERVER_IP \
|
||||
ssh -i ~/.ssh/deploy_key $DEPLOY_USER@$SERVER_IP \
|
||||
"cd $WEBSITE_DIR && docker compose restart maverick-website"
|
||||
|
||||
- name: Health check
|
||||
|
||||
Reference in New Issue
Block a user