How to generate the GitHub Personal Access Token for Infrastructure
Personal access tokens (PATs) are a secure way to grant third-party applications access to your GitHub account. They are an alternative to using your GitHub password, which can be more secure as they can be limited to specific scopes and can be revoked if they are compromised.
In this document, we will describe how to generate a classic PAT in GitHub and add it as a secret to the three UKSA repositories.
Generating a Classic Personal Access Token
Navigate to your GitHub settings: Click on your profile picture in the top right corner of any GitHub page and select “Settings” from the dropdown menu.
Access Developer Settings: In the left sidebar, click on “Developer settings”.
Generate a new token: Under the “Personal access tokens” section, click on “Generate new token”.
Provide a descriptive name: In the “Note” field, give your token a descriptive name so you can easily identify it later, e.g. “Terraform PAT”.
Set expiration: If you want your token to expire after a certain period, select “Expiration” and choose the desired expiration time. We expire after 30 days and regenerate.
Select permissions: Choose the permissions you want to grant to your token. We use the the token to access repositories, so select the “repo” scope.
Generate the token: Once you have selected the desired permissions, click on “Generate token”.
Copy and save the token: Your newly generated token will be displayed on the screen. Copy and save this token securely, as it will be needed later.
Adding the Token as a Secret to Repositories
Navigate to the repository settings: Go to the page of the repository where you want to add the token as a secret.
Access settings: Click on “Settings” in the top right corner of the repository page.
Open Secrets section: In the left sidebar, click on “Secrets and Variables” and select “Actions”.
Find the secret for the respective repo: Either
INFRA_REPO_TOKEN
(for sst-beta and sst-beta-python-backend) orTF_GITHUB_TOKEN
(for sst-beta-infra)Paste the token: In the “Value” field, paste the personal access token you generated earlier.
Save the secret: Click on “Update secret” to save the token as a secret for the repository.
Repeat for Additional Repositories
Repeat the process of adding the token as a secret for each repository.