Automatic Labeling Example
Automatically categorize PRs with intelligent labeling
This example shows how to implement comprehensive automatic labeling for pull requests based on various criteria including files changed, PR size, author team, and more.
Configuration
How It Works
This ruleset implements automatic labeling in two categories:
- Component Labeling: Labels PRs based on the types of files changed (frontend, backend, docs, infrastructure)
- Size Labeling: Labels PRs based on their size (small, medium, large, x-large)
The rules are designed to update the labels whenever a PR is opened or synchronized (new commits pushed).
Extending the Example
Change Type Labeling
Add labels based on the type of change:
Team-Based Labeling
Add labels based on the author’s team:
Priority Labeling
Add priority labels based on PR description:
Status Labeling
Add status labels based on validation results:
Best Practices for Label Management
Don’t create too many labels or overly complex labeling rules, as they can become difficult to maintain
Setting Up Required Labels
Before using this ruleset, create these labels in your repository:
-
Component labels:
component: frontend
(color: #0366d6)component: backend
(color: #6f42c1)component: docs
(color: #0075ca)component: infra
(color: #d73a4a)
-
Size labels:
size: small
(color: #c2e0c6)size: medium
(color: #fbca04)size: large
(color: #f9d0c4)size: x-large
(color: #e99695)
-
Type labels:
type: bug
(color: #d73a4a)type: feature
(color: #0075ca)type: docs
(color: #0366d6)type: refactor
(color: #6f42c1)
-
Team labels:
team: frontend
(color: #bfdadc)team: backend
(color: #c5def5)team: devops
(color: #dbedff)team: qa
(color: #d4c5f9)
-
Priority labels:
priority: high
(color: #d73a4a)priority: medium
(color: #fbca04)priority: low
(color: #0e8a16)
-
Status labels:
status: ready
(color: #0e8a16)status: needs-work
(color: #fbca04)status: review-required
(color: #d4c5f9)
Benefits of Automatic Labeling
- Consistency: Ensures PRs are labeled consistently according to rules
- Visibility: Makes it easy to filter and search PRs
- Workflow Integration: Labels can be used to drive other automations
- Reduced Manual Work: Eliminates the need for manual labeling
- Better Organization: Helps teams manage large volumes of PRs