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¶
- Go to your GitHub profile and open Settings.
- Click Developer settings in the sidebar.
- Click Personal access tokens.
- Click Generate new token.
- Name the token.
- Select scopes:
repo
(full control of private repositories)workflow
(run workflows)- Click Generate token.
- Copy the token. You won't be able to see it again.
2. Add the Token to Your Repository¶
- Go to your repository Settings.
- Click Secrets in the sidebar.
- Click New repository secret.
- Name the secret (e.g.,
GH_PAT
). - Paste the token into the Value field.
- Click Add secret.
3. Use the Token in GitHub Actions¶
Reference the secret in your workflow:
Keep your PATs private and use repository secrets