mirror of
https://github.com/prdlk/leetcode.git
synced 2026-09-16 23:16:26 +00:00
Add sync-d1 workflow: issue edits reconcile the catalog into D1
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
name: Sync D1 Catalog
|
||||||
|
|
||||||
|
# GitHub issues own the SRS catalog (topics, problems, set/diff labels,
|
||||||
|
# milestones); the Worker's D1 holds a reconciled copy. The 8 AM ET cron is
|
||||||
|
# the backstop — this workflow pushes curriculum edits into D1 immediately.
|
||||||
|
#
|
||||||
|
# The reconcile is a total recompute (never touches SRS-owned columns), so
|
||||||
|
# bursts can safely collapse to the last run: cancel-in-progress is correct.
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types:
|
||||||
|
[opened, edited, labeled, unlabeled, milestoned, demilestoned, reopened, transferred, deleted]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: sync-d1
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
reconcile:
|
||||||
|
# Only curriculum issues shape the catalog.
|
||||||
|
if: >-
|
||||||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
contains(github.event.issue.labels.*.name, 'problem') ||
|
||||||
|
contains(github.event.issue.labels.*.name, 'topic')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Reconcile catalog into D1
|
||||||
|
run: |
|
||||||
|
curl -sf -X POST -H "Authorization: Bearer $SRS_ADMIN_KEY" \
|
||||||
|
https://srs-api.prdlk.workers.dev/admin/reconcile
|
||||||
|
env:
|
||||||
|
SRS_ADMIN_KEY: ${{ secrets.SRS_ADMIN_KEY }}
|
||||||
@@ -36,7 +36,7 @@ flowchart LR
|
|||||||
| `scripts/` | Flat Bun TS: automation entries (shebang + top-level await) and libraries (no shebang, side-effect-free on import) |
|
| `scripts/` | Flat Bun TS: automation entries (shebang + top-level await) and libraries (no shebang, side-effect-free on import) |
|
||||||
| `docs/` | Blume site. `docs/solutions/(<category>)/<num>-<slug>.mdx` generated by sync; `(algorithms)/`, `(data-structures)/` hand-written explainers |
|
| `docs/` | Blume site. `docs/solutions/(<category>)/<num>-<slug>.mdx` generated by sync; `(algorithms)/`, `(data-structures)/` hand-written explainers |
|
||||||
| `api/` | Cloudflare Worker (own Bun workspace): `src/` modules, `data/schedule.json` (day → topic issue, human-edited, bundled at deploy), `migrations/`, `scripts/import-srs.ts` |
|
| `api/` | Cloudflare Worker (own Bun workspace): `src/` modules, `data/schedule.json` (day → topic issue, human-edited, bundled at deploy), `migrations/`, `scripts/import-srs.ts` |
|
||||||
| `.github/workflows/` | deploy (docs), close-solved, close-topics — Worker deploys are manual (`bun run api:deploy`) |
|
| `.github/workflows/` | deploy (docs), close-solved, close-topics, sync-d1 (issue edits → `/admin/reconcile`) — Worker deploys are manual (`bun run api:deploy`) |
|
||||||
|
|
||||||
## Development Commands
|
## Development Commands
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ routes). Bindings in `wrangler.jsonc`: `DB` (D1 `srs`), `EMAIL`
|
|||||||
(`send_email`, restricted to the verified destination). Sender domain
|
(`send_email`, restricted to the verified destination). Sender domain
|
||||||
`prdlk.com` is onboarded to Email Sending.
|
`prdlk.com` is onboarded to Email Sending.
|
||||||
|
|
||||||
|
The `sync-d1.yml` Actions workflow additionally pushes curriculum issue
|
||||||
|
edits into D1 immediately (`POST /admin/reconcile` with the
|
||||||
|
`SRS_ADMIN_KEY` repo secret); the morning cron is the backstop.
|
||||||
|
|
||||||
## Local dev
|
## Local dev
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
Reference in New Issue
Block a user