How to create a GitHub Access Token for deployment
This guide explains how to create a GitHub fine-grained Personal Access Token that you can use for deployments. This token allows CloudRay to securely clone your repositories during the deployment process.
Steps to create a token
-
Go to GitHub Settings:
- Log in to your GitHub account
- Click your profile picture in the top right
- Select “Settings”
-
Navigate to Developer Settings:
- Scroll to the bottom of the left sidebar
- Click “Developer settings”
-
Access Personal Access Tokens:
- Select “Fine-grained tokens”
- Click “Generate new token”
-
Configure the token:
- Name: Give your token a descriptive name (e.g., “CloudRay Deployments”)
- Expiration: Choose an expiration date (recommended: 1 year)
- Repository access: Select “Only select repositories” and choose your deployment repositories
- Permissions:
- Repository permissions:
- “Contents”: Read-only (needed for cloning)
- “Metadata”: Read-only (required by default)
- Repository permissions:
-
Generate and copy the token:
- Click “Generate token”
- Important: Copy the token immediately. GitHub will only show it once.
Using the token
When setting up your CloudRay variable group for deployments:
- Create a variable named
github_access_token
- Paste your GitHub token as the value
The token will be used in the format: https://{token}@github.com/{username}/{repo}
when cloning repositories.
Organization requirements
If your repository belongs to an organisation:
- The organisation must allow fine-grained tokens
- An organisation owner needs to enable fine-grained tokens:
- Go to Organization Settings > Third-party Access > Personal Access Tokens
- Click “Set organisation token policy”
- Enable “Allow fine-grained personal access tokens”
Security considerations
- Never share your token or commit it to your repository
- Use the minimum required permissions
- Regularly rotate your tokens by creating new ones and deleting old ones
- If a token is compromised, revoke it immediately in your GitHub settings
Token expiration
When your token expires:
- Create a new token following the steps above
- Update the
github_access_token
variable in your CloudRay variable group - The old token will automatically become invalid after expiration
That’s it! Your GitHub fine-grained Access Token is now ready to use with CloudRay deployment scripts.