name: Deploy FluentGerman.ai on: push: branches: [master] jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install dependencies run: | cd backend python -m venv venv source venv/bin/activate pip install -r requirements.txt - name: Run tests run: | cd backend source venv/bin/activate pip install aiosqlite python -m pytest tests/ -v --tb=short - name: Deploy to server env: DEPLOY_HOST: ${{ vars.DEPLOY_HOST }} DEPLOY_USER: ${{ vars.DEPLOY_USER }} DEPLOY_PATH: ${{ vars.DEPLOY_PATH }} SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} SSH_KNOWN_HOSTS: ${{ vars.SSH_KNOWN_HOSTS }} run: | # Write SSH credentials mkdir -p ~/.ssh echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts SSH_OPTS="-i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" # Sync backend (excluding .env and venv) rsync -avz --delete \ --exclude '.env' \ --exclude 'venv/' \ --exclude '__pycache__/' \ --exclude 'logs/' \ --exclude '*.pyc' \ -e "ssh $SSH_OPTS" \ backend/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/backend/ # Sync frontend rsync -avz --delete \ -e "ssh $SSH_OPTS" \ frontend/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/frontend/ # Install deps & restart on server ssh $SSH_OPTS ${DEPLOY_USER}@${DEPLOY_HOST} << REMOTE_SCRIPT set -e cd ${DEPLOY_PATH}/backend # Create venv if not exists if [ ! -d "venv" ]; then python3 -m venv venv fi source venv/bin/activate pip install --quiet -r requirements.txt # Restart service sudo systemctl restart fluentgerman echo "✓ FluentGerman.ai deployed and restarted" REMOTE_SCRIPT # Cleanup rm -f ~/.ssh/deploy_key