Skip to content

Git credentials are overwritten by this action #1210

@chelmertz

Description

@chelmertz

Describe the bug

This action overwrites already set git credentials, making later operations (like git push) fail.

To Reproduce

The order of these steps matter:

  1. Run actions/checkout@v4 with a GitHub App token that has push access (a bit old, unsure if it matters)
  2. Run claude-code-action@v1
  3. In a later step, run git push
    1. Push fails with Authentication failed

Log excerpt:

...

Download action repository 'anthropics/claude-code-action@v1' (SHA:b47fd721da662d48c5680e154ad16a73ed74d2e0)

...

remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/some-org/some-repo.git/'
Error: Process completed with exit code 1.

Expected behavior

The Claude action shouldn't affect the environment outside its own step. Github actions should use inputs/outputs to communicate.

At least, the observable behavior should be: the environment (including the git credentials) is the same before & after using this action.

Workflow yml file

Something like this:

steps:
  - name: Generate token
    id: app-token
    uses: actions/create-github-app-token@v2
    with:
      app-id: ${{ secrets.APP_ID }}
      private-key: ${{ secrets.PRIVATE_KEY }}

  - name: Checkout
    uses: actions/checkout@v4
    with:
      ref: ${{ github.head_ref }}
      token: ${{ steps.app-token.outputs.token }}

  - name: Run Claude
    uses: anthropics/claude-code-action@v1
    with:
      anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
      github_token: ${{ steps.app-token.outputs.token }}
      prompt: "Read foo.txt and write bar.txt"

  - name: Commit and push
    run: |
      git add -A
      git commit -m "update" || true
      git push origin HEAD
      # FAILS: remote: Invalid username or token.

API Provider

[x] Anthropic First-Party API (default)
[ ] AWS Bedrock
[ ] GCP Vertex

Additional context

Workaround: set .extraheader before pushing (steps.app-token refers to the example above):

- name: Commit and push
  env:
    APP_TOKEN: ${{ steps.app-token.outputs.token }}
  run: |
    git config --local http.https://github.com/.extraheader \
      "AUTHORIZATION: basic $(echo -n "x-access-token:${APP_TOKEN}" | base64 -w0)"
    git push origin HEAD

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:permissionsbugSomething isn't workingp2Non-showstopper bug or popular feature requestprovider:1pAnthropic First-Party API

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions