variables section configures repository-level variables for GitHub Actions. These variables can be referenced in workflow files and are useful for storing non-sensitive configuration values.
Basic Configuration
The name of the variable. Variable names are automatically converted to uppercase to match GitHub’s convention.
The value of the variable. All values are stored as strings, even if they appear numeric or boolean in the YAML.
Complete Examples
Basic Variables
Configuration Variables
Service URLs
Feature Flags
Variable Name Normalization
Variable names are automatically converted to uppercase by Safe Settings. This ensures consistency with GitHub’s variable naming convention:Using Variables in Workflows
Once configured, reference variables in your workflow files using thevars context:
Variables vs Secrets
Understand when to use variables vs secrets:Use Variables For:
- Non-sensitive configuration values
- Public API endpoints
- Feature flags
- Timeout values
- Version numbers
- Environment names
Use Secrets For:
- API keys and tokens
- Passwords
- Private keys
- Access credentials
- Any sensitive data
Variable Value Types
All variable values are stored as strings. If you need other types in workflows, convert them:String Values (Default)
Numeric Values (as Strings)
Boolean Values (as Strings)
JSON Values (as Strings)
Managing Variables
Creating Variables
Add variables to your settings file:Updating Variables
Change the value in your settings file:Deleting Variables
Remove the variable from your settings file. Safe Settings will delete variables that are not defined in the configuration.Best Practices
-
Use Uppercase Names: Follow GitHub’s convention
-
Quote Numeric and Boolean Values: Prevent YAML type conversion
-
Use Descriptive Names: Make variable purpose clear
-
Group Related Variables: Organize by function or service
-
Document Complex Values: Add comments for clarity
Environment-Specific Configuration
Use repository variables for environment-specific settings:Repository vs Environment Variables
Repository Variables
- Defined in the
variablessection - Available to all workflows in the repository
- Accessed with
${{ vars.VARIABLE_NAME }} - Managed by Safe Settings
Environment Variables
- Defined in the
environmentssection undervariables - Only available to jobs that use that environment
- Accessed with
${{ vars.VARIABLE_NAME }}when environment is specified - Also managed by Safe Settings
Viewing Variables
To view variables in GitHub:- Navigate to repository Settings
- Click “Secrets and variables” → “Actions”
- Click the “Variables” tab
Limitations
- Variable names must be uppercase (automatically converted by Safe Settings)
- Variable values are limited in size
- Variables are plaintext and visible to anyone with repository access
- Variables cannot contain sensitive information
- The total number of variables per repository may be limited