SSSK Monitor #1286
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: 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!" |