-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (98 loc) · 3.5 KB
/
Copy pathmonitor.yml
File metadata and controls
110 lines (98 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: SSSK Monitor
on:
schedule:
# Peak hours: 19:00 - 23:00 Kyiv (16:00 - 20:00 UTC) every 15 minutes
- cron: '*/15 16-20 * * *'
# Standard mode: Every 5 hours
- cron: '0 */5 * * *'
# Midnight Kyiv — switch tomorrow→today JSON for PWA
- cron: '0 21 * * *' # 00:00 Kyiv (summer EEST=UTC+3)
- cron: '0 22 * * *' # 00:00 Kyiv (winter EET=UTC+2)
workflow_dispatch:
inputs:
force:
description: 'Force heavy scan (bypass triggers)'
type: boolean
default: false
jobs:
parse:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y tesseract-ocr sqlite3
cd parser
pip install -r requirements.txt
playwright install --with-deps chromium
# ===== Chain 1: New Parser (SQLite pipeline) — may fail, that's OK =====
- name: Run Parser (SQLite pipeline)
continue-on-error: true
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: |
cd parser/src
if [ "${{ github.event.inputs.force }}" == "true" ]; then
python parse_schedule.py --force
else
python parse_schedule.py
fi
# ===== Chain 2: PWA pipeline (stable, keeps the app alive) =====
- name: Run History Crawler (JSON pipeline)
run: |
cd parser/src
python history_crawler.py
- name: Generate today/tomorrow JSON for PWA
env:
SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }}
SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}
run: |
cd parser/src
python generate_today.py
# ===== Debug: Check what was generated =====
- name: Debug Workspace
run: |
ls -R parser/data
if [ -f parser/data/schedules.db ]; then
sqlite3 parser/data/schedules.db "SELECT 'SQLite Rows: ' || count(*) FROM schedules;"
else
echo "SQLite DB not found - normal if no heavy scan occurred yet."
fi
# ===== Синхронізація з Supabase (Push-машина) =====
- name: Sync schedules to Supabase
env:
SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }}
SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}
run: |
cd parser
python sync_supabase.py
# ===== Commit results =====
- name: Commit and Push
id: commit
run: |
git config --global user.name "SSSK-Bot"
git config --global user.email "bot@svitlo-starkon.com"
git add parser/data/*.json web/public/data/*.json web/public/data/archive/*.json || true
if git commit -m "Auto-update schedules"; then
git push
echo "committed=true" >> $GITHUB_OUTPUT
else
echo "No changes to commit"
echo "committed=false" >> $GITHUB_OUTPUT
fi
# ===== Trigger deploy (GITHUB_TOKEN can't trigger on:push, but CAN trigger workflow_dispatch) =====
- name: Trigger Deploy
if: steps.commit.outputs.committed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run deploy.yml --ref main
echo "🚀 Deploy triggered!"