Skip to content

Centralize manifest+archive generation: workflow_dispatch on one central repo (zero YAML in dataset repos) #557

Closed

Description

@neuromechanist

Motivation

Today we copy a fan-out of CI workflows into every dataset repo via getWorkflowTemplates() + syncWorkflowTemplates():

nemarDatasets/<dataset>/.github/workflows/
├── bids-validation.yml
├── generate-archive.yml           ← repository_dispatch-driven
├── publish-version-doi.yml
├── pr-merge-handler.yml
├── version-doi-sync-trigger.yml
└── ... etc

Updating a single line in any of these requires syncWorkflowTemplates to fan-out a commit to N dataset repos. Today that's manageable; with 100+ datasets it's a maintenance tax for every CI tweak. It also means new datasets must run the deploy step before they can publish, instead of "exist + receive the App install = ready to go."

Companion issue: #556 (replacing the broken API-per-pointer manifest generation algorithm). That fix HAS to land somewhere with git available. Doing both at once removes the worker's manifest path entirely.

Proposal

Keep the existing repository_dispatch pattern from triggerArchiveGeneration — just point it at one central repo and have the workflow check out the target dataset at runtime instead of running inside it.

[Dataset repo: tag v1.0.0 pushed]
        ↓ (GH App "nemar-publish-bot" subscribed to push/tag events on the org)
[api.nemar.org/webhooks/dataset-release]  ← worker, signature-validated
        ↓
[POST repos/nemarOrg/<central>/dispatches  event_type=generate-manifest
   client_payload: { dataset_id, version, ref }]
        ↓
[Central repo workflow on GitHub-managed runner:]
  - actions/checkout@v4 with repo: nemarDatasets/${dataset_id} ref: v${version}
    (uses an App installation token minted server-side, passed as secret)
  - python emit_manifest.py  ← logic from #556 lives in this script
  - aws s3 cp manifest.json s3://nemar/${dataset_id}/version/v${version}.json
  - curl POST api.nemar.org/webhooks/manifest-ready
        ↓
[Worker manifest-ready handler: insert dataset_versions row, mint DOI]

What changes

Central repo (e.g., nemarOrg/nemar-cli or new nemarOrg/dataset-workflows):

Backend worker (nemar-cli/backend):

  • New POST /webhooks/dataset-release handler — signed webhook receiver from the GH App on tag events
  • New triggerManifestGeneration(dataset_id, version) mirroring triggerArchiveGeneration but pointing at the central repo
  • generateManifest() removed (or shrunk to a fallback)
  • getWorkflowTemplates() shrunk: drop publish-version-doi.yml, generate-archive.yml (caller side now lives centrally)
  • POST /webhooks/manifest-ready handler — central workflow callback that confirms upload + records dataset_versions row + mints DOI

Dataset repos (per-repo, one-time migration):

  • Delete publish-version-doi.yml, generate-archive.yml, version-doi-sync-trigger.yml after the central pipeline is verified end-to-end
  • Keep bids-validation.yml (per-repo CI on push) and any other repo-local workflows
  • Net: each dataset repo's .github/workflows/ shrinks by ~3 files

GitHub App config:

  • Subscribe to push events (tag-filtered) or release events on installed org
  • Add a webhook URL pointing at api.nemar.org/webhooks/dataset-release
  • App already has needed permissions (contents:write, metadata:read)

Pros

Cons / trade-offs

  • One central repo's Actions log becomes high-traffic (every publish for every dataset). Mitigation: filter by client_payload.dataset_id in the workflow run UI; runs auto-prune after 90 days anyway
  • App webhook is now critical-path for publishes — if signature validation breaks, no publishes work. Same risk class as today's webhook endpoint, just one more route
  • Minting an App installation token per workflow run requires a small server-side step (worker generates an ephemeral token, attaches as input to the dispatch). Standard pattern, well-trodden

Migration order (suggested phasing for the executor)

  1. PR-1: build the central workflow + emit_manifest.py script + triggerManifestGeneration in the worker. Wire the dataset-release webhook receiver but keep old publish-version-doi.yml path active. End-to-end test on nm099999 (test dataset).
  2. PR-2: dual-write phase — both the per-repo publish-version-doi.yml AND the centralized workflow fire for each publish, with the central one writing to a manifest_jobs table for verification. Compare manifests across the two paths for a week on real publishes. Resolve any divergence.
  3. PR-3: cut over. Delete per-repo workflows via syncWorkflowTemplates (it currently adds; teach it to remove). Remove generateManifest from worker.
  4. PR-4: migrate generate-archive to the same central pattern (separate but identical refactor).

Open decision

Central repo location:

  • (a) nemarOrg/nemar-cli — bundled with the existing backend code. Pro: monorepo, single PR for backend + workflow change. Con: nemar-cli already does many things.
  • (b) New nemarOrg/dataset-workflows — dedicated repo for centralized publish/archive workflows. Pro: clear separation of concerns. Con: another repo to maintain.

Recommend (a) for simpler ops; (b) only if nemar-cli's Actions tab gets too noisy.

References

Activity

  1. added
    P2
    feature
    on May 19, 2026
  2. added 2 commits that reference this issue on May 19, 2026
  3. neuromechanist commented on May 19, 2026

    @neuromechanist
    ContributorAuthor

    PR-1 landed in #563 (commit 8b2510d on dev). Behind feature flag MANIFEST_VIA_CENTRAL_WORKFLOW (default false). Old per-repo workflow path stays active as fallback.

    Remaining phasing (to be opened as separate sub-issues when work starts):

    • PR-2: dual-write — both inline path AND central path fire concurrently; compare manifests for a week of real publishes to surface any divergence before cutover
    • PR-3: cutover — flip flag to default true in prod, then delete per-repo publish-version-doi.yml via syncWorkflowTemplates (teach it to remove); remove worker fallback generateManifest()
    • PR-4: migrate generate-archive to the same central pattern

    Ops sequence (BLOCKS flag flip):

    • Set NEMAR_APP_ID, NEMAR_APP_PRIVATE_KEY, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, MANIFEST_CALLBACK_SECRET on nemarOrg/nemar-cli repo
    • Mirror MANIFEST_CALLBACK_SECRET as Workers secret on both prod + dev
    • Apply migration 0025 to D1 (prod + dev, both neuromechanist + sccn accounts)
    • Run nemar admin e2e-test --verbose against SCCN dev with flag=true to verify

    Keep this issue open until PR-2/PR-3/PR-4 land. Then close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions