Automation / How it updates
How the data updates
This section is a static site. There is no server and no live feed. A scheduled job refreshes one small data file, and the site is rebuilt and redeployed around it.
Pipeline
From race result to static page
- 01
Schedule
A GitHub Actions cron job starts every Monday at 06:00 UTC, the morning after a typical race weekend. It can also be started by hand from the Actions tab.
- 02
Fetch
scripts/sync-f1-telemetry.js asks the Jolpica API for the latest result, the next race on the calendar, and every finished round this season (winner, pole, fastest lap). If a request fails, the previous data is kept.
- 03
Commit
The script rewrites app/f1-tyres/data/latest-sync.json only if something changed. The workflow commits that file and pushes only when there is a diff.
- 04
Deploy
When data changed, the sync workflow calls the deploy workflow, which builds the site and publishes it to Cloudflare Pages. The JSON is imported at build time, so visitors get plain static HTML.
What is and is not automated
Automatic: the race calendar, the next Grand Prix, and each round's winner, pole and fastest lap. By hand: Pirelli's compound nominations for each race, kept with a source link in app/f1-tyres/data/season2026.js, and the compound guide and 2023–24 strategy archive in app/f1-tyres/data/f1Data.js. Pirelli does not publish its nominations through an API.
Current snapshot
What this build contains
The values below were read from latest-sync.json when the site was built.
- Data last updated
- 2026-11-16 14:32 UTC
- Race
- Brazilian Grand Prix (2026, round 20)
- Circuit
- Autódromo José Carlos Pace
- Race date
- 2026-11-08
- Winner
- Lando Norris (McLaren), 71 laps in 1:35:23.504
- Fastest lap
- Andrea Kimi Antonelli (Mercedes), 1:12.689 on lap 55
- Source
- https://api.jolpi.ca/ergast/f1/
Try it
Query the source yourself
This is a real request from your browser to the same API the sync job uses. It is a check, not a sync: it does not update the site.
Check the API from your browser
Requests https://api.jolpi.ca/ergast/f1/current/last/results.json directly. Nothing is saved and the site data is not changed.
Source
The workflow and the script
Both files are read from the repository at build time, so what you see here is what runs.
.github/workflows/f1-tyre-sync.yml
name: F1 tyre data sync
# Pulls the latest finished race result from the Jolpica F1 API into
# app/f1-tyres/data/latest-sync.json, commits it when it changed, and then
# runs the deploy workflow so the result reaches tenziki.com. (A push made
# with the default GITHUB_TOKEN does not trigger other workflows by itself,
# which is why the deploy is called from here explicitly.)
on:
schedule:
# Mondays at 06:00 UTC, the morning after a typical race weekend.
- cron: '0 6 * * 1'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: f1-tyre-sync
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
changed: ${{ steps.commit.outputs.changed }}
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 22
- name: Fetch the latest race result
run: node scripts/sync-f1-telemetry.js
- name: Commit the data file if it changed
id: commit
run: |
if git diff --quiet -- app/f1-tyres/data/latest-sync.json; then
echo "latest-sync.json is unchanged. Nothing to commit."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
git config user.name "f1-tyre-sync[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add app/f1-tyres/data/latest-sync.json
git commit -m "Sync latest F1 race result"
git push
echo "changed=true" >> "$GITHUB_OUTPUT"
deploy:
needs: sync
if: needs.sync.outputs.changed == 'true'
uses: ./.github/workflows/deploy.yml
secrets: inheritscripts/sync-f1-telemetry.js
/**
* Sync Formula 1 race data into app/f1-tyres/data/latest-sync.json:
* - latestFinishedRace: winner and fastest lap of the most recent race
* - nextRace: the next round on the calendar (name, circuit, dates, sprint or not)
* - season: every finished round this season with its winner, pole sitter and fastest lap
*
* Source: Jolpica-F1 (the community-run, open-source Ergast replacement). No API key needed.
* Run by .github/workflows/f1-tyre-sync.yml; safe to run locally with `node scripts/sync-f1-telemetry.js`.
*
* Behaviour:
* - Each request has a timeout and a couple of retries. If the next-race or season request fails,
* the previous values for that part are kept; only the latest-race request is required.
* - If the API is unreachable, slow, or returns nothing usable, the existing JSON file is left untouched
* and the script exits 0 (a warning is printed; it is a transient condition, not a failure).
* - The file is only rewritten when the race data actually changed, so an unchanged week produces no diff.
* - The script exits 1 only for genuine local errors, such as being unable to read or write the file.
*/
const fs = require('node:fs');
const path = require('node:path');
const SOURCE = 'https://api.jolpi.ca/ergast/f1/';
const ENDPOINT = `${SOURCE}current/last/results.json`;
const NEXT_ENDPOINT = `${SOURCE}current/next.json`;
const WINNERS_ENDPOINT = `${SOURCE}current/results/1.json?limit=100`;
const POLES_ENDPOINT = `${SOURCE}current/qualifying/1.json?limit=100`;
const FASTEST_ENDPOINT = `${SOURCE}current/fastest/1/results.json?limit=100`;
const OUT_PATH = path.join(__dirname, '..', 'app', 'f1-tyres', 'data', 'latest-sync.json');
const TIMEOUT_MS = 15000;
const ATTEMPTS = 3;
const RETRY_DELAY_MS = 3000;
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
/** GitHub Actions turns `::warning::` lines into annotations; elsewhere it is just a readable line. */
function warn(message) {
console.warn(`::warning::[F1-SYNC] ${message}`);
}
function fullName(driver) {
return driver ? `${driver.givenName} ${driver.familyName}` : undefined;
}
async function fetchOnce(url) {
const res = await fetch(url, {
signal: AbortSignal.timeout(TIMEOUT_MS),
headers: { Accept: 'application/json', 'User-Agent': 'tenziki-f1-tyre-sync' },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}
async function fetchWithRetry(url = ENDPOINT) {
let lastError;
for (let attempt = 1; attempt <= ATTEMPTS; attempt += 1) {
try {
return await fetchOnce(url);
} catch (err) {
lastError = err;
console.log(`[F1-SYNC] Attempt ${attempt}/${ATTEMPTS} failed: ${err.message}`);
if (attempt < ATTEMPTS) await wait(RETRY_DELAY_MS);
}
}
throw lastError;
}
/** Reduce the API response to the small structure the site displays. */
function toRaceSummary(json) {
const race = json?.MRData?.RaceTable?.Races?.[0];
if (!race || !Array.isArray(race.Results) || race.Results.length === 0) return null;
const winner = race.Results.find((r) => r.position === '1') || race.Results[0];
const fastest = race.Results.find((r) => r.FastestLap?.rank === '1');
const summary = {
season: race.season,
round: race.round,
name: race.raceName,
circuit: race.Circuit?.circuitName,
date: race.date,
winner: {
driver: fullName(winner.Driver),
team: winner.Constructor?.name,
laps: winner.laps,
time: winner.Time?.time,
},
};
if (fastest) {
summary.fastestLap = {
driver: fullName(fastest.Driver),
team: fastest.Constructor?.name,
time: fastest.FastestLap?.Time?.time,
lap: fastest.FastestLap?.lap,
};
const speed = fastest.FastestLap?.AverageSpeed?.speed;
if (speed) summary.fastestLap.speedKmh = speed;
}
return summary;
}
/** The next round on the calendar, or null once the season is over. */
function toNextRace(json) {
const race = json?.MRData?.RaceTable?.Races?.[0];
if (!race) return null;
const loc = race.Circuit?.Location || {};
return {
season: race.season,
round: race.round,
name: race.raceName,
circuit: race.Circuit?.circuitName,
circuitId: race.Circuit?.circuitId,
locality: loc.locality,
country: loc.country,
date: race.date,
time: race.time,
firstPractice: race.FirstPractice?.date,
qualifying: race.Qualifying?.date,
sprint: Boolean(race.Sprint),
};
}
/** Every finished round this season, joined from the winners, poles and fastest-lap tables. */
function toSeason(winnersJson, polesJson, fastestJson) {
const races = winnersJson?.MRData?.RaceTable?.Races;
if (!Array.isArray(races) || races.length === 0) return null;
const byRound = (json) => new Map((json?.MRData?.RaceTable?.Races || []).map((r) => [r.round, r]));
const poles = byRound(polesJson);
const fastest = byRound(fastestJson);
return {
year: races[0].season,
races: races.map((r) => {
const win = r.Results?.[0];
const pole = poles.get(r.round)?.QualifyingResults?.[0];
const fl = fastest.get(r.round)?.Results?.[0];
const row = {
round: r.round,
name: r.raceName,
circuit: r.Circuit?.circuitName,
date: r.date,
winner: win ? { driver: fullName(win.Driver), team: win.Constructor?.name } : null,
pole: pole ? { driver: fullName(pole.Driver), team: pole.Constructor?.name, time: pole.Q3 || pole.Q2 || pole.Q1 } : null,
fastestLap: fl ? { driver: fullName(fl.Driver), team: fl.Constructor?.name, time: fl.FastestLap?.Time?.time } : null,
};
return row;
}),
};
}
/** Optional parts: on failure, warn and fall back to what the file already had. */
async function optional(label, fn, fallback) {
try {
return await fn();
} catch (err) {
warn(`${label} unavailable (${err.message}); keeping the previous value.`);
return fallback;
}
}
function readExisting() {
try {
return JSON.parse(fs.readFileSync(OUT_PATH, 'utf8'));
} catch (err) {
if (err.code === 'ENOENT') return null;
// A corrupt file will simply be replaced by fresh data.
console.log(`[F1-SYNC] Existing file could not be parsed (${err.message}); it will be replaced.`);
return null;
}
}
async function main() {
console.log(`[F1-SYNC] Fetching ${ENDPOINT}`);
let json;
try {
json = await fetchWithRetry();
} catch (err) {
warn(`Jolpica API unavailable (${err.message}). Keeping the existing data file unchanged.`);
return;
}
const latest = toRaceSummary(json);
if (!latest) {
warn('The API responded but returned no race results. Keeping the existing data file unchanged.');
return;
}
console.log(`[F1-SYNC] Latest race: ${latest.name} (${latest.season} round ${latest.round}), ${latest.date}`);
console.log(`[F1-SYNC] Winner: ${latest.winner.driver} (${latest.winner.team})`);
if (latest.fastestLap) {
console.log(`[F1-SYNC] Fastest lap: ${latest.fastestLap.driver}, ${latest.fastestLap.time} on lap ${latest.fastestLap.lap}`);
}
const existing = readExisting();
const nextRace = await optional('Next race', async () => toNextRace(await fetchWithRetry(NEXT_ENDPOINT)), existing?.nextRace ?? null);
console.log(nextRace ? `[F1-SYNC] Next race: ${nextRace.name} (round ${nextRace.round}), ${nextRace.date}` : '[F1-SYNC] No next race (season over).');
const season = await optional(
'Season results',
async () => {
const [w, p, f] = [await fetchWithRetry(WINNERS_ENDPOINT), await fetchWithRetry(POLES_ENDPOINT), await fetchWithRetry(FASTEST_ENDPOINT)];
const result = toSeason(w, p, f);
if (!result) throw new Error('no finished races');
return result;
},
existing?.season ?? null
);
if (season) console.log(`[F1-SYNC] Season ${season.year}: ${season.races.length} finished rounds`);
const data = { latestFinishedRace: latest, nextRace, season };
const before = existing ? { latestFinishedRace: existing.latestFinishedRace, nextRace: existing.nextRace ?? null, season: existing.season ?? null } : null;
if (before && JSON.stringify(before) === JSON.stringify(data)) {
console.log('[F1-SYNC] No change since the last sync. Nothing written.');
return;
}
const payload = {
lastSyncedAt: new Date().toISOString(),
source: SOURCE,
...data,
};
fs.writeFileSync(OUT_PATH, `${JSON.stringify(payload, null, 2)}\n`, 'utf8');
console.log(`[F1-SYNC] Wrote ${path.relative(process.cwd(), OUT_PATH)}`);
}
main().catch((err) => {
console.error(`[F1-SYNC] Sync failed: ${err.stack || err.message}`);
process.exit(1);
});Setup
Keeping it running
- Keep the repository on GitHub with Actions enabled. The workflow needs the default contents: write permission, which the file already requests.
- Deploys run from .github/workflows/deploy.yml on every push to main. It needs two repository secrets: CLOUDFLARE_API_TOKEN (a token limited to Pages) and CLOUDFLARE_ACCOUNT_ID.
- To test the job without waiting for Monday, open the Actions tab, choose F1 tyre data sync and press Run workflow.
- Pushes made by a workflow with the default token do not start other workflows, which is why the sync calls the deploy workflow directly rather than relying on its own push.
The Jolpica API is free and needs no key, but it is community run and rate limited, which is why the script keeps the previous file whenever a request fails.
Next