From a2d9bb4404c2acf78425310fad9ede40efa95a27 Mon Sep 17 00:00:00 2001 From: Paddy <89168564+patrickballard@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:45:54 +0000 Subject: [PATCH] Link brand.css with a version, and check it in CI GitHub Pages lets browsers reuse a file for 10 minutes, so after a deploy a returning visitor could get the new HTML with the old brand.css (the new popover menu then showed as a full-screen box on phones). index.html now links /brand.css?v=, so a changed stylesheet gets a new URL. The site has no build step, so the version is written by hand; a new Check workflow fails when it doesn't match the file and prints the line to use. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/check.yml | 40 +++++++++++++++++++++++++++++++++++++ index.html | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..4f85cd6 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,40 @@ +name: Check + +# The site has no build step, so its pages link brand.css with a version written by hand: /brand.css?v= and the first +# 10 hex of the file's sha256. GitHub Pages lets a browser reuse a file for 10 minutes, and the version gives a changed +# stylesheet a new URL, so a returning visitor never gets new HTML with an old cached brand.css. This fails when a +# page's version doesn't match the file, and prints the line to use. + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Stylesheet versions + run: | + python3 - <<'PY' + import hashlib, pathlib, re, sys + bad = 0 + for page in sorted(pathlib.Path(".").glob("*.html")): + text = page.read_text(encoding="utf-8") + for m in re.finditer(r'', text): + want = hashlib.sha256(pathlib.Path(m[1]).read_bytes()).hexdigest()[:10] + if m[2] != want: + print(f'::error file={page}::{m[0]} should be ') + bad += 1 + if re.search(r']*\bsrc=", text): + print(f"::error file={page}::links a stylesheet or script this check doesn't know; version it and extend the check") + bad += 1 + sys.exit(1 if bad else 0) + PY diff --git a/index.html b/index.html index 0b80b5f..da4105e 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@ - +