Weekly puzzle workflow: Sunday 03:37 UTC, commit the data to main, redeploy the live release with it through release.yml; releases ship every weekly from main
This commit is contained in:
parent
372893ec75
commit
2ac9143db9
2 changed files with 107 additions and 1 deletions
28
.github/workflows/release.yml
vendored
28
.github/workflows/release.yml
vendored
|
|
@ -4,7 +4,8 @@ name: Release to GitHub Pages
|
|||
# Pushes to main run CI but never deploy. To ship: bump "version" in
|
||||
# package.json and date its CHANGELOG section; auto-release.yml then tags,
|
||||
# publishes the release and starts this workflow from the tag. Publishing a
|
||||
# release by hand works too.
|
||||
# release by hand works too. Every Sunday weekly-puzzle.yml redeploys the live
|
||||
# release from its tag with the new weekly puzzle added (input weekly).
|
||||
on:
|
||||
release:
|
||||
# "released" also fires when a pre-release is promoted to a full release.
|
||||
|
|
@ -18,6 +19,10 @@ on:
|
|||
description: Allow deploying a version older than what is live (rollback)
|
||||
type: boolean
|
||||
default: false
|
||||
weekly:
|
||||
description: Only the weekly puzzles changed (weekly-puzzle.yml); the release itself was tested when it shipped
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
# Least privilege: only the deploy job can write to Pages.
|
||||
permissions:
|
||||
|
|
@ -63,8 +68,28 @@ jobs:
|
|||
if [ "$ALLOW_OLDER" != "true" ] && [ "$(printf '%s\n%s\n' "$live" "$new" | sort -V | tail -n1)" != "$new" ]; then
|
||||
echo "::error::$new is older than the live $live. Re-run with allow_older to roll back on purpose."; exit 1
|
||||
fi
|
||||
# Weekly puzzles are published on main between releases (weekly-puzzle.yml). Every deploy ships all of them,
|
||||
# so neither a release nor a weekly redeploy ever drops a week that is already out.
|
||||
- name: Weekly puzzles from main
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch --no-tags --depth=1 origin main
|
||||
if git cat-file -e FETCH_HEAD:site/puzzles/weekly 2>/dev/null; then
|
||||
rm -rf site/puzzles/weekly
|
||||
git checkout FETCH_HEAD -- site/puzzles/weekly
|
||||
echo "Weekly puzzles: $(ls site/puzzles/weekly | grep -c '^[0-9].*\.json$')"
|
||||
fi
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
if: ${{ !inputs.weekly }}
|
||||
- name: Check the weekly puzzles against this release
|
||||
if: ${{ inputs.weekly }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# A release from before the weekly puzzles ships the files without reading them: nothing to check.
|
||||
if [ ! -f scripts/weekly-puzzle.js ]; then echo "This release does not read weekly puzzles yet."; exit 0; fi
|
||||
node scripts/weekly-puzzle.js --check
|
||||
npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js
|
||||
- name: Build site
|
||||
run: VERSION="${TAG#v}" REQUIRE_NOTES=1 npm run build
|
||||
- uses: actions/upload-pages-artifact@v5
|
||||
|
|
@ -88,6 +113,7 @@ jobs:
|
|||
# the site is live.
|
||||
indexnow:
|
||||
needs: deploy
|
||||
if: ${{ !inputs.weekly }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# IndexNow keys are public by design (also served at /<key>.txt).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue