Repository navigation
Phase 4: dataset-repo workflows use App-minted tokens (#439) - #444
Merged
neuromechanist merged 2 commits intoMay 11, 2026
Conversation
Migrates the 4 `secrets.GITHUB_TOKEN` references in pr-merge,
llm-enrichment, and version-doi over to App-issued installation tokens
via actions/create-github-app-token@v1.
Original epic scope said "replace secrets.NEMAR_GITHUB_PAT" but the
audit found no NEMAR_GITHUB_PAT in any workflow template. Rescoped
with user approval: end state is unified bot identity
(nemar-publish-bot[bot]) for every CI write in dataset repos, matching
the Worker's auth path now that Phase 3 has routed orchestrator calls
through the App.
backend/src/services/github.ts:
- pr-merge.yml `create-release` job: prepend the app-token step,
override actions/checkout `token:` to the App, swap `GH_TOKEN` env
for the App, and bump the local git author/email to
`nemar-publish-bot` to match the resulting commit identity on the
release tag.
- llm-enrichment.yml `enrich` job: prepend app-token step, override
checkout `token:` so subsequent `git commit` + `git push` of the
enrichment metadata authenticate as the App.
- version-doi.yml `publish-doi` job: prepend app-token step, swap
`GH_TOKEN` for the App so `gh release view`/`gh release create`
attribute the release to the App.
- version-doi.yml `trigger-archive` job: prepend app-token step (the
second one in this template by design — each job mints its own
token), swap `GH_TOKEN` for the App so the
`gh api repos/.../dispatches` call carries Actions: write from the
App's installation.
The `repositories: ${{ github.event.repository.name }}` scope on every
app-token step gives least-privilege: even if a workflow misbehaves,
the token can only write to its own dataset repo.
docs/guides/github-app-setup.md:
- Bump the Actions permission in the install instructions from
Read-only to Read & write (the new `gh api dispatches` call needs
Actions: write).
- New "Phase 4: dataset-repo CI uses the same App" section with the
3 ops steps: accept the permission upgrade, set NEMAR_APP_ID +
NEMAR_APP_PRIVATE_KEY org-level secrets on nemarDatasets, then
refresh existing dataset repos via `nemar admin ci add`.
- Phase 4 acceptance checklist.
test/workflow-yaml.test.ts:
- New test: each of the three migrated templates has an
actions/create-github-app-token@v1 step with the right inputs and
zero `secrets.GITHUB_TOKEN` references.
- New test: version-doi has exactly two app-token steps (one per job).
- New test: the three NOT-migrated templates (bids-validation,
version-check, generate-archive) have no create-github-app-token
reference, so future drift in either direction gets caught.
13/13 workflow-yaml tests pass (was 10). tsc --noEmit clean.
Sanity guarantees:
- `grep -c secrets.GITHUB_TOKEN backend/src/services/github.ts` → 0
(was 4 before this PR).
- `grep -c create-github-app-token backend/src/services/github.ts` → 4
(pr-merge×1 + llm-enrichment×1 + version-doi×2).
Rollout (ops, after merge):
1. Accept the App permission upgrade in the GitHub UI on both org
installations.
2. Set NEMAR_APP_ID + NEMAR_APP_PRIVATE_KEY org secrets on
nemarDatasets (visibility: All repositories).
3. Refresh existing dataset repos: `nemar admin ci add <id>` for each,
or the bulk sweep pattern proven in the May 2026 archive-refresh
pass.
Closes #439. Part of epic #432.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR444Version: 🤖 Updated on each push. |
code-reviewer: - llm-enrichment.yml git config used nemar-bot / [email protected], contradicting the unified bot identity goal. Swap to nemar-publish-bot to match pr-merge and so commit author records the App identity authentication uses for the push. pr-test-analyzer: - Reparse migrated templates via the existing YAML parser and assert structural invariants: - The app-token step is at index 0 (must precede checkout/gh calls that reference its outputs). - with.app-id, with.private-key, with.owner, with.repositories are pinned to the exact expected values (not just substring presence; catches a hardcoded `repositories: nm000103`). - Every GH_TOKEN env block in migrated jobs points at steps.app-token.outputs.token (catches partial migrations). comment-analyzer: - Drop "Phase 4" framing from runbook section heading + body + subheading. The chronological anchor lives in commits and the epic issue, not in long-lived ops docs. - Drop `(#439)` from test name; project rule on rot-prone refs. - Collapse the 4-bullet test comment that restated each expect() into one WHY line. Defer with PR note (silent-failure-hunter HIGH findings): - Pre-check guard for missing org secrets — single extra step per job; the runbook is explicit and the failure shape, while not ideal, is recoverable in one ops cycle. - 403-on-dispatch hint — operationally acceptable; cause is named in the error body. - Tag-push branch-protection hint — current allowlist includes the bot; if that changes, follow-up. - repositories: scope fallback — every current trigger populates github.event.repository.name; defensive fallback can land when a new trigger shape is added. - Two-mint silent drop in version-doi — orchestrator's generate_archive retry path covers it; in-workflow warning would add noise without a clearer recovery action. 13/13 tests pass (was 10 with 114 expect() calls). tsc --noEmit clean.
Contributor
Author
Review findings addressed (commit da04c70)Four reviews aggregated.
On the deferred silent-failure findingsThese are real concerns but I traded the in-template instrumentation for cleaner workflows and a more explicit runbook:
If any of (1)–(5) turn out to bite in practice during the rollout, they're each ~5-line additions and can ship as Phase 4 follow-ups without disturbing the structural pattern this PR lands. 13/13 tests pass, 114 `expect()` calls (was 103). `tsc --noEmit` clean. |
neuromechanist
merged commit May 11, 2026
01dc9ae
into
feature/issue-432-epic-github-app
1 check passed
This was referenced May 11, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the 4 `secrets.GITHUB_TOKEN` references in `pr-merge`, `llm-enrichment`, and `version-doi` workflow templates to App-issued installation tokens via `actions/create-github-app-token@v1`.
Original epic scope said "replace `secrets.NEMAR_GITHUB_PAT`" — audit showed no such reference in any workflow template. With user sign-off, rescoped to migrate the `secrets.GITHUB_TOKEN` usages so every dataset-repo CI write carries `nemar-publish-bot[bot]` identity, matching the Worker's auth path now that Phase 3 routes orchestrator calls through the App.
Sanity guarantees
What this PR ships
pr-merge.ymlcreate-release job: app-token step prepended; `actions/checkout` token, `GH_TOKEN` env, and git author/email all swap to the App.llm-enrichment.ymlenrich job: app-token step + checkout `token:` override so commit + push of enrichment metadata authenticate as the App.version-doi.yml: app-token step in BOTH jobs (publish-doi for `gh release create`, trigger-archive for `gh api repos/.../dispatches`).What's NOT in this PR
Rollout (ops, after merge)
```
nemar admin ci add
```
Or sweep via the bulk pattern proven in the May 2026 archive-refresh.
Until step 3 happens for a given dataset, that dataset's CI keeps running the old template with `secrets.GITHUB_TOKEN` — no breakage, gradual rollout.
Test plan
Closes #439. Part of epic #432.