Phase 7a: real 6:00am n8n schedule for the school brief (AUD-115)

The 06:00 workflow is now one schedule-trigger -> Execute Command pair that
runs scripts/morning-brief.sh on the host over a restricted SSH key. The
earlier scan -> HTTP shape could not work: the n8n container cannot resolve
the `remote` ssh alias (its ~/.ssh/config is a dangling nix symlink) and a
split scan node hides scan failures before the notify node runs.

- deploy/n8n-morning-brief.json: two-node workflow, scheduleTrigger v1.3
- deploy/setup-n8n-scan-key.sh: restricted (restrict,command=) trigger key
- deploy/import-n8n-morning-brief.sh: import + publish + restart + verify
- deploy/DEPLOYMENT.md, Makefile: document and expose both scripts (dry run)
- docs/phase-7a-n8n-schedule.md: design, verification, failure drill

Import into the shared n8n service still needs Sam's approval.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-10-15 19:51:36 +11:00
parent 9cbfa7db9b
commit 7d367f7712
6 changed files with 316 additions and 53 deletions

View File

@@ -96,8 +96,16 @@ the API directly on the internal address.
docker exec compass-teams-nhs /app/school notify status
```
5. Import `deploy/n8n-morning-brief.json` in n8n, set `SCHOOL_NOTIFY_TOKEN` in
the n8n environment, and activate the workflow (06:00 daily, Australia/Melbourne).
5. Schedule the 06:00 daily run in n8n (Phase 7a, AUD-115):
```bash
deploy/setup-n8n-scan-key.sh --apply # restricted SSH key for the trigger
deploy/import-n8n-morning-brief.sh --apply # import + publish + restart n8n
```
The workflow has one Execute Command node: `ssh … 'scripts/morning-brief.sh'`.
It needs no `SCHOOL_NOTIFY_TOKEN` in n8n — the host script reads the project env
file. See `docs/phase-7a-n8n-schedule.md` for the design and the failure drill.
Notes:
@@ -109,3 +117,7 @@ Notes:
service image. `scripts/morning-brief.sh` runs the scan and the send in order.
- A run that cannot deliver exits non-zero, and the endpoint answers `207`, so a
broken morning is visible in n8n instead of silent (FR-12).
- The 06:00 schedule is the n8n workflow `Compass / NHS — 6:00am morning brief`
(`deploy/n8n-morning-brief.json`), triggered over a restricted SSH key. It runs
on the shared n8n service on `.13`, so its import, publish, and the one-off n8n
restart need approval first.