Skip to content

GitHub Personal Access Token

Personal access tokens (PATs) are a secure way to authenticate with a Git server without using your GitHub password. PATs are similar to SSH keys: you create a token and use it instead of your password for HTTPS authentication.


PATs are required for operations like pushing changes from GitHub Actions. They use the HTTPS URL, not the git@ SSH syntax.

How to Create and Use a Personal Access Token

1. Create a Personal Access Token

  1. Go to your GitHub profile and open Settings.
  2. Click Developer settings in the sidebar.
  3. Click Personal access tokens.
  4. Click Generate new token.
  5. Name the token.
  6. Select scopes:
  7. repo (full control of private repositories)
  8. workflow (run workflows)
  9. Click Generate token.
  10. Copy the token. You won't be able to see it again.

2. Add the Token to Your Repository

  1. Go to your repository Settings.
  2. Click Secrets in the sidebar.
  3. Click New repository secret.
  4. Name the secret (e.g., GH_PAT).
  5. Paste the token into the Value field.
  6. Click Add secret.

3. Use the Token in GitHub Actions

Reference the secret in your workflow:

- uses: agithubrepo/somecoolapp@v0.0.1
  with:
    gh_token: ${{ secrets.GH_PAT }}

Keep your PATs private and use repository secrets