GitHub Service Account
GitHub Service Account a regular GitHub user account that is used to perform automated tasks in GitHub repositories. It is a best practice to use a service account for automation tasks instead of using personal accounts.
Create a New GitHub User
- Go to GitHub → Sign up.
- Choose a username as
<organization-name>-devops
and use email address as[email protected]
which is ideally a distribution list. - Set a strong password and enable 2FA.
- Click on Create account and verify your email address.
Protect Account With 2FA
- Go to Settings → Password and authentication → Two-factor authentication.
- Setup Authenticator app and SMS as backup between two persons.
- Keep Recovery codes in a secure vault.
Create Personal Access Token
- Go to Settings → Developer settings → Personal access tokens → Fine-grained tokens.
- Click on Generate new token.
- Give a descriptive name i.e
Commit ECR Image Tags PAT
. - Select the service account user as Resource Owner.
- Set No expiration.
- In the Description, add the purpose of the token i.e "Once container image is built and pushed to ECR from Application repository, commit new image tag in IaC repository".
- Under Respositories, select
All repositories
. - Under Permissions, set
Read and write
for Contents. - Click on Generate token and copy the token to a secure vault.
Add Service Account User to The Repository
In the repository where you want to commit the image tag
- Go to Settings → Collaborators and teams → Add people.
- Add the service account user.
- Choose Write role.
- Click add.
Accept Invite
- Login to the service account user.
- Click on Notification icon. You will see an invite for repository access.
- Click on the invite and accept it.