Remove ssh debug, add rsync

This commit is contained in:
2025-07-01 15:11:25 -06:00
parent f7af26c661
commit a54cfba761

View File

@ -10,7 +10,7 @@ on:
- 'css/**' - 'css/**'
- 'js/**' - 'js/**'
- 'images/**' - 'images/**'
workflow_dispatch: workflow_dispatch: # Now available in 1.24.2!
jobs: jobs:
deploy: deploy:
@ -27,70 +27,33 @@ jobs:
- name: Setup SSH - name: Setup SSH
run: | run: |
echo "🔧 Setting up SSH configuration..."
mkdir -p ~/.ssh 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 echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key
# Debug: Verify key file was created # Use relaxed host checking
if [ ! -f ~/.ssh/deploy_key ]; then echo "Host *" > ~/.ssh/config
echo "❌ Failed to create SSH key file" echo " StrictHostKeyChecking no" >> ~/.ssh/config
exit 1 echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config
fi chmod 600 ~/.ssh/config
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"
- name: Deploy website - name: Deploy website
run: | run: |
# Server configuration # Install rsync
SERVER_IP="192.168.4.56" # Your server IP echo "📦 Installing rsync..."
DEPLOY_USER="deploy" # The user we just created 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" WEBSITE_DIR="/media/stephen/Storage_Linux/infrastructure/services/websites/maverickApplications"
echo "📁 Syncing files to server..." echo "📁 Syncing files to server..."
rsync -avz --delete \ rsync -avz --delete \
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \ -e "ssh -i ~/.ssh/deploy_key" \
./ $DEPLOY_USER@$SERVER_IP:$WEBSITE_DIR/ ./ $DEPLOY_USER@$SERVER_IP:$WEBSITE_DIR/
echo "🔄 Restarting website container..." 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" "cd $WEBSITE_DIR && docker compose restart maverick-website"
- name: Health check - name: Health check