Why Restrict Repositories?
You may want to exclude certain repositories from Safe Settings management for several reasons:- Special-purpose repos: Admin, config, or tooling repositories
- External projects: Forked or imported repositories
- Legacy systems: Repos with custom configurations not yet migrated
- Test repositories: Temporary or experimental repos
- Manual control: Repos requiring hands-on management
Configuration Location
Restricted repositories are configured indeployment-settings.yml, which should be located in the directory where Safe Settings runs (not in your admin repository).
Default Behavior
Without adeployment-settings.yml file, Safe Settings automatically excludes:
admin.githubsafe-settings
Configuration Syntax
Simple Array (Include Only)
The simplest form lists repositories to include:deployment-settings.yml
When using simple array syntax, these are treated as repositories to exclude (for backward compatibility).
Include and Exclude
For more control, use explicitinclude and exclude lists:
deployment-settings.yml
Pattern Matching
Restricted repos support glob-style pattern matching using the* wildcard.
Wildcard Examples
Pattern Matching Rules
*matches any characters (including none)- Patterns are case-sensitive
- Exact names take precedence over patterns
- Quote patterns that start with special characters
Include vs Exclude Logic
Include Only
When onlyinclude is specified, Safe Settings runs only on repositories that match the patterns:
api-gateway, api-users, web-app, web-admin. Ignores everything else like mobile-app, docs, infrastructure.
Exclude Only
When onlyexclude is specified, Safe Settings runs on all repositories except those matching the patterns:
admin, 2023-archive, old-archive, test-api, test-web, etc.
Include and Exclude Combined
When both are specified:- Repository must match an
includepattern - Repository must NOT match an
excludepattern
include defines the allowlist, then exclude removes exceptions from it.
api-gateway✅ Managed (matches include, not excluded)api-legacy❌ Ignored (matches include but also excluded)api-users-archive❌ Ignored (matches include but also excluded by pattern)web-app✅ Managed (matches include, not excluded)mobile-app❌ Ignored (doesn’t match include)
Complete Examples
Example 1: Manage Only Production Services
deployment-settings.yml
prod-apiprod-webcore-authcore-database
dev-apistaging-webprod-legacy-deprecatedtest-anything
Example 2: Exclude Test and Archive Repos
deployment-settings.yml
Example 3: Team-Based Repository Groups
deployment-settings.yml
frontend-webfrontend-mobilebackend-apibackend-workersshared-utils
frontend-example(excluded)devops-tools(doesn’t match include)shared-template(excluded)
Example 4: Protect Critical Infrastructure
deployment-settings.yml
Integration with Settings
Restricted repos work at the repository level, before any settings are applied.Flow
- Event received (push, repo created, etc.)
- Safe Settings checks if repository matches restrictions
- If restricted: Stop processing, no changes made
- If not restricted: Load and apply org/suborg/repo settings
Per-Repository Override
You cannot overriderestrictedRepos on a per-repository basis. The restriction is a deployment-level setting that applies globally.
To make exceptions:
- Use more specific patterns
- Adjust include/exclude rules
Use Cases
Progressive Rollout
Start with a small set of repositories, then expand:Multi-Environment Management
Manage different environments separately:deployment-settings.yml (Production Safe Settings)
deployment-settings.yml (Staging Safe Settings)
Organization Divisions
Manage repositories by business unit or division:deployment-settings.yml (Division A Safe Settings)
deployment-settings.yml (Division B Safe Settings)
Best Practices
Use Consistent Naming
Adopt repository naming conventions that work with patterns:Document Your Patterns
Add comments explaining your restriction strategy:deployment-settings.yml
Test Pattern Changes
Before deploying restriction changes:- List your repositories
- Test patterns against the list
- Verify included/excluded repos are correct
Start Restrictive, Then Open Up
It’s safer to start with a narrowinclude list and expand:
Exclude Dangerous Patterns
Always exclude repositories that could break your setup:Troubleshooting
Repository Not Being Managed
Problem: Repository should be managed but Safe Settings ignores it. Debug steps:- Check if repo name matches
includepatterns - Verify repo name doesn’t match
excludepatterns - Check for typos in pattern matching
- Review logs for restriction messages
Repository Being Managed When It Shouldn’t
Problem: Repository is being modified but should be restricted. Debug steps:- Verify
deployment-settings.ymlis in correct location - Check YAML syntax (proper indentation)
- Verify patterns are correctly formatted
- Check if there’s a more specific include pattern
Pattern Not Matching
Problem: Pattern seems correct but doesn’t match expected repos. Common issues:Deployment Settings Not Loading
Problem: Changes todeployment-settings.yml don’t take effect.
Solutions:
- Restart Safe Settings application
- Verify file location (same directory as running app)
- Check file permissions (readable by Safe Settings)
- Validate YAML syntax
Environment Variables
You can customize the deployment settings file location:Advanced Patterns
Multiple Wildcard Matching
Complex Boolean Logic
Temporary Exclusions
Validation
Test your restricted repos configuration:Related Configuration
Restricted repos work alongside:- Custom Validators - Additional validation logic
- Suborg Configuration - Repository grouping
- Per-Repository Settings - Individual repo config