DEV Community

Cover image for A site that has to change at midnight: daily data with GitHub Actions and static hosting
Crane Zhou
Crane Zhou

Posted on AI-assisted

A site that has to change at midnight: daily data with GitHub Actions and static hosting

I built a small fan site, Krillion Answer Key, that lists the day's answers to a daily trivia game. The game publishes one answer sheet a day and only keeps the current day public. So the site has one job with a deadline: shortly after midnight US Eastern, fetch the new sheet, keep it, and republish. A day that is missed cannot be fetched later.

The site is a static export (Next.js) on Cloudflare Workers static assets. There is no server and no database. Here is what the daily job looks like and what I learned.

1. The data lives in the repo. A script fetches the sheet and appends the day to one JSON file. Every page is generated from that file at build time: the home page is the newest day, each day and each prompt gets its own page, and a "yesterday" page appears once there are two days. Git history is the backup.

2. Trim before you store. The raw sheet is about 7.5 MB: more than 100,000 accepted answers across seven prompts, most of them in one tier. I keep the top answer, the small tiers in full, and an evenly spread sample of the large ones. A day ends up around 24 KB.

3. Scheduled workflows start late, so schedule several. GitHub's cron can start minutes late under load. The workflow runs a few times in the hour after the reset, and again later as a safety net. The script is idempotent: if today is already saved it exits without doing anything, and the build step is skipped.

4. Daylight saving moves the deadline. Midnight Eastern is 05:00 UTC in winter and 04:00 UTC in summer, and cron is in UTC. Rather than changing the schedule twice a year, the workflow runs after both hours and the script works out the date itself with Intl.DateTimeFormat and the America/New_York zone.

5. Commit first, deploy second. The job commits the new JSON, then builds and deploys. If the deploy fails, the data is already safe and the next run can redeploy.

6. Give CI the smallest key that works. The deploy token can edit Workers scripts and the routes of one zone, and nothing else.

7. Have a way to test the fetch without saving. A --probe flag fetches and reports the size of the sheet. I run it on manual dispatch, which is how I checked that GitHub's runners could reach the source at all.

The fetch script and workflow are on GitHub: fancydirty/krillion-answer-key.

Disclosure: I run the site, which is an independent fan site and not affiliated with the game. This post was drafted with AI assistance from my own code and notes.

Top comments (0)