Repository navigation
ci: scope down release/sync-docs to dedicated GitHub Apps - #297
Conversation
Replace the over-privileged shared CI bot with two dedicated, minimally scoped GitHub Apps gated behind protected environments. - publish.yml: rename environment npm -> Publish, switch from tibdex/github-app-token@v2 (archived) to actions/create-github-app-token@v3 with vars.PUBLISH_CI_APP_CLIENT_ID + secrets.PUBLISH_CI_APP_KEY. - sync-docs.yml (renamed from cli-docs.yml for cross-repo consistency with genlayer-testing-suite): bump create-github-app-token to @V3, switch to client-id, gate behind the Sync-docs environment with vars.DOCS_SYNC_APP_CLIENT_ID + secrets.DOCS_SYNC_APP_KEY. Each App should be installed only on the repos it needs (Publish: this repo only; Sync-docs: this repo + genlayer-docs) with Contents: read & write as the only permission.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughWorkflows for publishing and documentation sync were updated to use ChangesGitHub Actions Token Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/sync-docs.yml:
- Around line 14-15: The workflow currently sets permissions: contents: read
which prevents the "Commit and push docs back to CLI repo" step from pushing via
GITHUB_TOKEN; update the workflow permissions to grant write access (change or
replace contents: read with contents: write) so the checkout/push step can
authenticate and push release updates, and ensure any job-level or step-level
permissions do not override this change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5fab3ab6-4c0e-49a3-b16c-957839a79e11
📒 Files selected for processing (2)
.github/workflows/publish.yml.github/workflows/sync-docs.yml
| permissions: | ||
| contents: read |
There was a problem hiding this comment.
contents: read will cause the CLI-repo git push to fail on releases.
The "Commit and push docs back to CLI repo" step (line 61) writes back to the CLI repo via GITHUB_TOKEN (the initial actions/checkout@v4 at line 17 uses no explicit token). With only contents: read, that push will always get a 403 on non-draft release events.
The PR notes acknowledge this gap ("a step that writes docs may require contents: write"). The fix is straightforward:
🔒 Proposed fix
permissions:
- contents: read
+ contents: write🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/sync-docs.yml around lines 14 - 15, The workflow currently
sets permissions: contents: read which prevents the "Commit and push docs back
to CLI repo" step from pushing via GITHUB_TOKEN; update the workflow permissions
to grant write access (change or replace contents: read with contents: write) so
the checkout/push step can authenticate and push release updates, and ensure any
job-level or step-level permissions do not override this change.
- Mint Sync-docs App token before CLI checkout, scope to both genlayer-cli and genlayer-docs. - Use App token for the initial CLI checkout so the docs-back-to-main push is authed as the App (which is on the main bypass list), not as github-actions[bot]. - Push as `origin HEAD:main` so release-tag triggered runs (detached HEAD) can find a target ref.
Summary
Reduce the attack surface of release & docs-sync workflows by replacing the shared, over-privileged CI bot with two dedicated, minimally scoped GitHub Apps gated behind protected environments. Mirrors the same change in genlayer-testing-suite#78.
publish.yml— environment renamednpm→Publish, switched from the archivedtibdex/github-app-token@v2to the officialactions/create-github-app-token@v3. Readsvars.PUBLISH_CI_APP_CLIENT_IDandsecrets.PUBLISH_CI_APP_KEY.sync-docs.yml(renamed fromcli-docs.ymlfor cross-repo consistency withgenlayer-testing-suite) — bumpedactions/create-github-app-tokento@v3, switched to the explicitclient-idparameter, gated behind theSync-docsenvironment. Readsvars.DOCS_SYNC_APP_CLIENT_IDandsecrets.DOCS_SYNC_APP_KEY. Cross-reporepositories: genlayer-docstoken request is preserved.Each App should be installed only on the repos it needs (Publish: this repo only; Sync-docs: this repo +
genlayer-docs) withContents: Read & writeas the only permission.Pre-merge checklist (GitHub side)
Publishenvironment exists withPUBLISH_CI_APP_CLIENT_ID(variable) andPUBLISH_CI_APP_KEY(secret)NPM_TOKEN(or whatever release-it uses for npm publish) from the oldnpmenvironment into the newPublishenvironment, then delete thenpmenvironmentSync-docsenvironment exists withDOCS_SYNC_APP_CLIENT_ID(variable) andDOCS_SYNC_APP_KEY(secret)genlayer-cli(sync-docs App also ongenlayer-docs) with onlyContents: Read & writePublishApp added to branch-protection bypass list onmainandstaging(release-it pushes the version-bump commit + tag)Sync-docsenvironment "Deployment branches and tags" allows thev*tag pattern (otherwiserelease: publishedon a tag ref will be blocked)Test plan
fix:orfeat:commit onstagingand confirmpublish.ymlmints a token, release-it pushes the version bump + tag, the GitHub Release is created, and the npm beta upload succeedsmainfor a stable releasesync-docs.ymlfires automatically onrelease: publishedand pushes the API-reference update togenlayer-docsNotes / follow-ups
sync-docs.ymljob-levelpermissions: contents: readis left as-is in this PR. The "commit and push docs back to CLI repo" step (line ~52-63) writes to the CLI repo using the defaultGITHUB_TOKEN, which would requirecontents: write. Either that step has never produced a diff, or it's been silently failing — worth verifying separately.Summary by CodeRabbit