Add git `insteadof` example by multimeric · Pull Request #273 · actions/create-github-app-token

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds documentation for configuring Git to use GitHub App tokens for authentication, addressing issue #270. The addition provides guidance for scenarios where tools use Git directly but cannot accept GitHub API tokens.

  • Adds a new documentation section explaining Git's insteadof configuration option
  • Provides a complete workflow example for Python projects with private Git dependencies
  • Includes additional configuration examples for repository and organization-specific authentication
# required
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Configure git to use the app token

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.

- 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.

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"

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.

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.