Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,44 @@ jobs:
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}
```

### Tell git to use the app token to authenticate

Certain tools use `git` to access repositories, but have no facility to accept a GitHub API token.
In this scenario it's easier to configure `git` itself to use the token.
For example, this is important if you have a Python project with a `git+https` or a `git+ssh` dependency on a private repository.

```yaml
on: [pull_request]

jobs:
python-build:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v2
id: app-token
with:
# required
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Configure git to use the app token
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The placeholder 'USERNAME' in the Git URL is not explained. Consider clarifying what value should be used here or if it's a literal placeholder that Git ignores for token-based authentication.

Suggested change
- name: Configure git to use the app token
- name: Configure git to use the app token
# The USERNAME part of the URL can be any non-empty string (e.g., 'x-access-token'), as GitHub ignores it when a token is used.

Copilot uses AI. Check for mistakes.

run: git config --global url."https://USERNAME:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- uses: actions/setup-python@v5
- name: Install dependencies
run: pip install .
```

Refer to [`git`'s configuration docs](https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlbaseinsteadOf) for more information on this syntax.

In this example, `USERNAME` is ignored by GitHub since the token contains the full authentication information. For this reason, you can leave it in the configuration as is.

The above example will use the same token for all `git` operations on GitHub via `https`, but you can configure it on a per repository or per-organisation basis by changing the prefix:

```bash
git config --global url."https://USERNAME:${GITHUB_TOKEN}@github.com/MyOrg/MyRepo".insteadOf "https://github.com/MyOrg/MyRepo"
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example uses the same unexplained 'USERNAME' placeholder. For consistency and clarity, this should match the explanation provided for the main example above.

Suggested change
git config --global url."https://USERNAME:${GITHUB_TOKEN}@github.com/MyOrg/MyRepo".insteadOf "https://github.com/MyOrg/MyRepo"
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/MyOrg/MyRepo".insteadOf "https://github.com/MyOrg/MyRepo"

Copilot uses AI. Check for mistakes.

```

## Inputs

### `app-id`
Expand Down