Repository navigation
Fix Claude action pushing with the read-only workflow token - #1493
Conversation
actions/checkout@v7 persists the GITHUB_TOKEN header through includeIf.gitdir entries, which claude-code-action does not clear (anthropics/claude-code-action#1721). The header overrides the Claude app token on git push, so pushes fail with a 403 under contents: read. Stop persisting the checkout credentials so the app token is used.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Checkout retains read access and Claude retains separate write access for PR updates, so this change presents no actionable merge-blocking risk. Pre-merge checks |
|
Summary
@claudecould comment on PRs but not push to them. Pushes failed with:Example: #1486 (comment) (run).
Cause
actions/checkout@v7persists theGITHUB_TOKENauth header in a separate credentials file, included throughincludeIf.gitdir:git config entries.claude-code-action@v1only clears the header from local config andinclude.path, so it logsNo existing authentication headers to removeand the header stays.git pushauthenticates asgithub-actions[bot]withcontents: read.This is anthropics/claude-code-action#1721, still open upstream.
Fix
Set
persist-credentials: falseon the checkout step, so the app token is the only git credential. This is the workaround reported in that issue and in anthropics/claude-code-action#1877.The documented alternative is granting the workflow
contents: write. I did not take it: the push would then go out asgithub-actions[bot], which does not triggerCheckson Claude's commits, and it widens the workflow token.Known caveat
persist-credentials: falsebreaks this action on private repositories, because it fetches the PR branch before configuring its own auth (anthropics/claude-code-action#1711). This repository is public, so that fetch works anonymously.Verification
npm run format: no fixes appliednpm run lint: no fixes appliedNot tested end to end. The workflow can only be exercised by an
@claudechange request on a PR once this change is in place.Not breaking
Only
.github/workflows/claude.ymlchanges. No package code, public API or published artefact is affected.