anthropics / anthropics/claude-code-action

configureGitAuth function incompatible with actions/checkout@v4.3.1,v5.0.1,v6

Open
#907 1 comment 4 reactions 0 assignees View on GitHub
area:permissions bug p2 provider:1p
Dominant language
TypeScript
Stars
8.9k
Forks
2.1k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

## Description

The Claude GitHub App is installed on our repository with **Read and write** permissions for Contents, Pull Requests, and Issues (confirmed via the installation settings page). However, the installation token returned by the OIDC exchange does not have write access to repository contents, causing `git push` to fail with a 403.

## Reproduction

1. Install the official Claude GitHub App with Read & Write for code, PRs, and issues
2. Configure workflow with `claude_code_oauth_token` and `id-token: write`
3. Trigger Claude on a PR (in our case, created by a different GitHub App bot)
4. Claude commits locally, then runs `git push origin HEAD`

## Error

```
remote: Write access to repository not granted.
fatal: unable to access 'https://github.com//.git/': The requested URL returned error: 403
```

## Diagnostics

We had Claude run diagnostic commands during a workflow run:

- **OIDC exchange succeeds**: Logs show `App token successfully obtained`
- **Git remote URL is correctly rewritten**: `https://x-access-token:REDACTED@github.com/...`
- **Token lacks write permissions**:
```json
// gh api /installation/repositories --jq '.repositories[0].permissions'
{"admin": false, "maintain": false, "pull": false, "push": false, "triage": false}
```
- **Push dry-run confirms the 403**
- **App installation page confirms**: Read and write access to code, discussions, issues, pull requests, and workflows
- **Claude CAN comment on issues and PRs**, so the token has some write permissions — just not contents

## Configuration

```yaml
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read

steps:
- uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
additional_permissions: |
actions: read
```

The `additional_permissions` input means the exchange request should include `{contents: "write", pull_requests: "write", issues: "write", actions: "read"}` per the source in `token.ts`.

## Workaround

Passing an explicit `github_token` input (from a separate GitHub App via `actions/create-github-app-token`) bypasses the OIDC exchange and works.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.