Skip to content

Commit f273abc

Browse files
Create deploy.yml
1 parent 0d7e8f6 commit f273abc

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: UptimeMonitor CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Create virtual environment and install dependencies
23+
run: |
24+
python -m venv venv
25+
source venv/bin/activate
26+
pip install --upgrade pip
27+
pip install -r requirements.txt
28+
29+
- name: Check if app starts
30+
env:
31+
FLASK_APP: app.py
32+
FLASK_ENV: development
33+
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
34+
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
35+
run: |
36+
source venv/bin/activate
37+
38+
python -c '
39+
import subprocess
40+
import time
41+
import requests
42+
43+
# Запускаем Flask в фоне
44+
server = subprocess.Popen(["python", "app.py"])
45+
time.sleep(5) # Ждём старта сервера
46+
47+
# Проверяем доступность /
48+
try:
49+
response = requests.get("http://localhost:5000")
50+
assert response.status_code == 200, f"App failed to start: {response.status_code}"
51+
print("✅ App is running and responding!")
52+
except Exception as e:
53+
print(f"❌ Error: {e}")
54+
exit(1)
55+
finally:
56+
server.terminate()
57+
'

0 commit comments

Comments
 (0)