From 3d2689b1971946c008618e23a4e0ec5108649aaf Mon Sep 17 00:00:00 2001 From: stephenminakian Date: Tue, 1 Jul 2025 14:38:49 -0600 Subject: [PATCH] Add website deployment workflow --- .gitea/workflows/deploy-website.yaml | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .gitea/workflows/deploy-website.yaml diff --git a/.gitea/workflows/deploy-website.yaml b/.gitea/workflows/deploy-website.yaml new file mode 100644 index 0000000..e8719ed --- /dev/null +++ b/.gitea/workflows/deploy-website.yaml @@ -0,0 +1,71 @@ +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 \ No newline at end of file