File Location
Deployment settings are stored indeployment-settings.yml in the directory where Safe Settings is running:
Unlike repository settings (which are in the admin repo), deployment settings live alongside the Safe Settings application.You can customize the file location using the
DEPLOYMENT_CONFIG_FILE environment variable (default: deployment-settings.yml).Restricted Repositories
Control which repositories Safe Settings can manage using therestrictedRepos configuration.
Default Behavior
If nodeployment-settings.yml file exists, Safe Settings excludes these repositories by default:
admin.githubsafe-settings
Exclude Repositories
Prevent Safe Settings from managing specific repositories:deployment-settings.yml
When to use exclude
When to use exclude
Use
exclude when you want Safe Settings to manage most repositories except a few:- Administrative repositories
- Legacy repositories
- Repositories managed by other tools
- Personal/test repositories
Include Repositories
Only allow Safe Settings to manage specific repositories:deployment-settings.yml
When to use include
When to use include
Use
include when you want to:- Gradually roll out Safe Settings to your organization
- Limit Safe Settings to specific project areas
- Test Safe Settings on a subset of repositories
Combine Include and Exclude
You can use bothinclude and exclude together:
deployment-settings.yml
deployment-settings.yml
How include/exclude work together:
- If only
excludeis specified → Run on all repos except excluded ones - If only
includeis specified → Run only on included repos - If both are specified → Run only on included repos that aren’t excluded
Pattern Matching
Pattern matching uses glob expressions:Config Validators
Config validators enforce global rules on settings, regardless of hierarchy level. They validate a setting on its own.Example: Prevent Admin Collaborators
Prevent anyone from assigning admin permissions to collaborators:deployment-settings.yml
Example: Enforce Topics
Require all repositories to have at least one topic:deployment-settings.yml
Example: Validate Branch Names
Ensure branch protection is only applied to valid branch names:deployment-settings.yml
Config validator script details
Config validator script details
Config validators have access to:
baseconfig- The configuration being validatedgithubContext- GitHub API context
trueif validation passesfalseif validation fails (error message will be shown)
Override Validators
Override validators control whether suborg or repo-level settings can override org-level settings. They validate the relationship between base and override configurations.Example: Prevent Weakening Branch Protection
Prevent repos from requiring fewer approvals than the org level:deployment-settings.yml
Example: Prevent Disabling Features
Prevent repos from disabling security features:deployment-settings.yml
Example: Require Minimum Status Checks
Ensure repos don’t remove required status checks:deployment-settings.yml
Override validator script details
Override validator script details
Override validators have access to:
baseconfig- The base configuration (from org or suborg level)overrideconfig- The overriding configuration (from suborg or repo level)githubContext- GitHub API context
trueif the override is allowedfalseif the override should be rejected (error message will be shown)
Validator Plugin Names
Validators use plugin names to determine which settings they validate:| Plugin Name | Settings Validated |
|---|---|
repository | Repository settings |
branches | Branch protection rules |
collaborators | Collaborator access |
teams | Team access |
labels | Labels |
milestones | Milestones |
autolinks | Autolinks |
validator | Repository name validation |
rulesets | Repository rulesets |
environments | Deployment environments |
custom_properties | Custom properties |
variables | Repository variables |
Complete Example
Here’s a comprehensive deployment settings file:deployment-settings.yml
Testing Validators
Test your validators by creating a PR in your admin repo that should fail validation:Check Results
The check run should fail with your custom error message. Verify the error is clear and helpful.
Validator Best Practices
Clear Error Messages
Write descriptive error messages that explain what’s wrong and how to fix it.
Handle Edge Cases
Check for
null, undefined, and missing properties before accessing nested values.Log Context
Use
console.log to debug your validators. Logs appear in Safe Settings output.Return Boolean
Always return
true or false. Other return values will cause errors.Common Validator Patterns
- Range Validation
- Required Fields
- Pattern Matching
- Whitelist
Troubleshooting
Validator not running
Validator not running
Check:
- Is the plugin name correct? Must match one of the valid plugin names.
- Is the YAML valid? Validate with a YAML linter.
- Is the
deployment-settings.ymlfile in the correct location? - Check Safe Settings logs for script errors.
Script syntax errors
Script syntax errors
Common issues:
- Missing return statement
- Using
varinstead ofconstorlet - Accessing properties that might not exist (use optional chaining:
?.) - Incorrect comparison operators
Validator always passes/fails
Validator always passes/fails
Add console.log statements to debug:
Next Steps
Sample Deployment Settings
View complete sample configuration
Configuration Hierarchy
Understand when validators run
Environment Variables
Configure Safe Settings runtime behavior
Custom Validators Guide
Advanced validator examples