name: Deploy Website run-name: Deploying website changes by ${{ github.actor }} on: push: branches: [ main ] paths: - '*.html' - 'assets/**' - 'css/**' - 'js/**' - 'images/**' workflow_dispatch: 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 echo "Host *" > ~/.ssh/config echo " StrictHostKeyChecking no" >> ~/.ssh/config echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config chmod 600 ~/.ssh/config - name: Deploy website run: | # 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 website files to server..." rsync -avz --delete \ --no-times \ --no-perms \ --exclude='.git' \ --exclude='.gitea' \ --exclude='README.md' \ --exclude='docker-compose.yml' \ -e "ssh -i ~/.ssh/deploy_key" \ ./ $DEPLOY_USER@$SERVER_IP:$WEBSITE_DIR/ echo "🔄 Restarting website container..." ssh -i ~/.ssh/deploy_key $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