Update deploy.yml #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: UptimeMonitor CI/CD | ||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| jobs: | ||
| build-and-test: | ||
| 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.11' | ||
| - name: Create virtual environment and install dependencies | ||
| run: | | ||
| python -m venv venv | ||
| source venv/bin/activate | ||
| pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| - name: Check if app starts | ||
| env: | ||
| FLASK_APP: app.py | ||
| FLASK_ENV: development | ||
| TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} | ||
| TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | ||
| run: | | ||
| source venv/bin/activate | ||
| python -c ' | ||
| import subprocess | ||
| import time | ||
| import requests | ||
| # Запускаем Flask в фоне | ||
| server = subprocess.Popen(["python", "app.py"]) | ||
| time.sleep(5) # Ждём старта сервера | ||
| # Проверяем доступность / | ||
| try: | ||
| response = requests.get("http://localhost:5000") | ||
| assert response.status_code == 200, f"App failed to start: {response.status_code}" | ||
| print("✅ App is running and responding!") | ||
| except Exception as e: | ||
| print(f"❌ Error: {e}") | ||
| exit(1) | ||
| finally: | ||
| server.terminate() | ||
| ' | ||