Repository Filter
Filter rules based on repository properties
The Repository Filter allows you to apply rules based on repository properties such as name, visibility, and topics. This is useful when you have the same ruleset configuration across multiple repositories but want certain rules to apply only to specific repositories.
Configuration
Must be set to "repository"
Repository visibility to match (“public” or “private”)
Conditions for repository name
Repository name patterns that should match
Repository name patterns that should not match
Conditions for repository topics
Repository topic patterns that should match
Repository topic patterns that should not match
Basic Usage
Examples
Repository Visibility
Apply a rule only to public repositories:
Or only to private repositories:
Repository Name Matching
Apply a rule only to repositories with specific names:
Or use patterns to match repository names:
Repository Topics
Apply a rule only to repositories with specific topics:
Or exclude repositories with certain topics:
Combined Criteria
Combine multiple repository properties:
Pattern Matching
The Repository Filter supports several pattern matching methods:
- Exact match:
"api"
- Glob patterns:
"api-*"
- Regular expressions:
"/^api-v\\d+$/"
(enclosed in forward slashes)
How It Works
Get Repository Information
The filter retrieves basic repository information from the event context
Check Visibility
If visibility
is specified, it checks if the repository visibility matches
Check Name Patterns
If name
conditions are specified, it checks if the repository name matches the requirements
Get Repository Topics
If topics
conditions are specified, it retrieves the repository topics
Check Topic Patterns
It checks if the repository topics match the specified requirements
Determine Result
Returns a match result based on whether all specified conditions are satisfied
Practical Use Cases
Different Rules by Repository Type
Apply different rules based on repository purpose:
Public vs Private Repository Rules
Apply stricter rules to public repositories:
Repository Name Patterns
Apply rules based on repository name patterns:
Topic-Based Requirements
Enforce specific requirements based on repository topics:
Best Practices
Repository topics must be set manually before they can be used in filters
Managing Repository Topics
To maximize the effectiveness of the Repository Filter with topics:
- Define a Taxonomy: Create a standard set of topics for your organization
- Document Topics: Document the meaning and usage of each topic
- Apply Consistently: Apply topics consistently across repositories
- Review Regularly: Periodically review and update repository topics
To add topics to a repository:
- Go to the repository’s main page
- Click “About” on the right side
- Click the gear icon next to the About section
- Add topics in the “Topics” field
- Click “Save changes”