Something went wrong. Try again.
Advanced metrics for pesäpallo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990name: Daily data refresh
# Re-ingests the current pesäpallo season from pesistulokset.fi, re-exports the# static site/data, and commits the diff so Vercel redeploys. Historical seasons# are static, so only the current year is fetched each day (polite to the API);# the full SQLite DB is kept in the Actions cache between runs so career pages# still export with complete history. If the cache is ever empty, the workflow# rebuilds the full 1990→ history first.
on: schedule: - cron: '17 5 * * *' # daily, 05:17 UTC workflow_dispatch: {} # allow manual runs from the Actions tab
permissions: contents: write
concurrency: group: data-refresh cancel-in-progress: false
jobs: refresh: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- uses: actions/setup-python@v5 with: python-version: '3.12'
- name: Restore the SQLite DB (full history) from cache uses: actions/cache@v4 with: path: data/pesis.db key: pesis-db-${{ github.run_id }} restore-keys: | pesis-db-
- name: Backfill full history if the cache was empty run: | if [ ! -s data/pesis.db ]; then echo "No cached DB — running the one-time 1990→ backfill." python -m pesis ingest-v1 --from-year 1990 --to-year "$(date +%Y)" --series all fi
- name: Backfill Suomensarja history if the cached DB predates it # Suomensarja joined --series all in July 2026. A DB cached before # that has no Suomensarja seasons, so fetch its 2001→ history once; # after that (and after full rebuilds, which include it) this is a # no-op. Data exists from 2001, with gaps handled by per-year skips. run: | if ! python -c "import sqlite3, sys; c = sqlite3.connect('data/pesis.db'); sys.exit(0 if c.execute(\"SELECT 1 FROM seasons WHERE series = 'Miesten Suomensarja' OR series = 'Naisten Suomensarja' LIMIT 1\").fetchone() else 1)"; then echo "No Suomensarja in the cached DB — backfilling 2001→." python -m pesis ingest-v1 --from-year 2001 --to-year "$(date +%Y)" --series suomensarja-miehet python -m pesis ingest-v1 --from-year 2001 --to-year "$(date +%Y)" --series suomensarja-naiset fi
- name: Ingest the current season run: python -m pesis ingest-v1 --year "$(date +%Y)" --series all
# Play-by-play for played matches of the current season. Matches without # live scoring are marked missing on first attempt and never refetched, # so after the initial season backfill this is a handful of calls a day. - name: Ingest play-by-play for the current season run: python -m pesis ingest-pbp --year "$(date +%Y)"
- name: Re-export the static data run: | rm -rf site/data python export.py
- name: Commit and push if anything changed run: | git config user.name "mallo-bot" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add site/data if git diff --cached --quiet; then echo "No data changes today." else git commit -m "Daily data refresh ($(date -u +%F))" # main may have moved while the (long) ingest ran; the commit # only touches site/data, so rebasing onto the new tip is safe for i in 1 2 3; do git pull --rebase origin main && git push && break echo "push attempt $i failed, retrying" sleep 10 done fi