name: Deploy Website run-name: Deploying website changes by ${{ github.actor }} on: push: branches: [ main ] paths: - '*.html' - 'assets/**' - 'css/**' - 'js/**' - 'images/**' jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Validate HTML run: | apt-get update && apt-get install -y tidy find . -name "*.html" -exec tidy -q -e {} \; echo "✅ HTML validation passed" - name: Setup SSH run: | mkdir -p ~/.ssh echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key # Get your server's IP (replace with your actual IP) SERVER_IP="192.168.1.20" # Change this to your server's IP ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts - name: Deploy website run: | # Server configuration SERVER_IP="192.168.1.20" # Your server IP DEPLOY_USER="deploy" # The user we just created 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" \ ./ $DEPLOY_USER@$SERVER_IP:$WEBSITE_DIR/ echo "🔄 Restarting website container..." ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no $DEPLOY_USER@$SERVER_IP \ "cd $WEBSITE_DIR && docker compose restart maverick-website" - name: Health check run: | echo "🏥 Waiting for container to restart..." sleep 15 for i in {1..5}; do if curl -f --connect-timeout 10 https://maverickapplications.com; then echo "✅ Website is responding correctly!" exit 0 fi echo "⏳ Attempt $i failed, retrying in 10 seconds..." sleep 10 done echo "❌ Website health check failed" exit 1 - name: Cleanup if: always() run: rm -f ~/.ssh/deploy_key