Auto-Label Issue Areas Workflow
Overview
The Auto-Label Issue Areas workflow automatically processes issues to:
- Extract area labels from the "Areas Affected" field in bug reports
- Prefix issue titles based on the issue template type (Bug, Feature Request, Question, etc.)
- Apply area labels to help categorize and route issues to the appropriate maintainers
Purpose
- Automated Categorization: Reduces manual labeling effort
- Consistent Formatting: Ensures issue titles follow a standard format
- Better Organization: Helps maintainers quickly identify issue scope
- Template Integration: Works with GitHub issue form templates
Trigger Conditions
Events
issueswith types:opened- When a new issue is creatededited- When an existing issue is edited (allows re-labeling if areas change)
Permissions
issues: write- Required to modify issue labels and titles
Workflow Structure
Job: label-areas
Runner: ubuntu-latest
Steps:
- Extract and apply area labels
- Uses
actions/github-script@v8to execute JavaScript - Processes issue body and title
- Extracts area information
- Applies labels and updates title
- Uses
Detailed Behavior
Title Prefixing Logic
The workflow automatically prefixes issue titles based on template type and labels:
| Template Type | Prefix | Detection Criteria |
|---|---|---|
| Bug Report | [Bug]: |
Has bug label OR contains "### Steps to Reproduce" |
| Feature Request | [Feature Request]: |
Has enhancement, new-feature, or suggestion label OR contains "### Feature Description" |
| Other Issues | [Other Issues]: |
Has discussion or other label OR contains "### Please describe your issue" |
| Question | [Question]: |
Has question label OR contains "### What do you want to ask?" |
Rules:
- Only applies to newly opened issues (not edits)
- Skips if title already has the correct prefix
- Applies the first matching template type
Area Label Mapping
The workflow maps area names from issue forms to GitHub labels:
| Area Name | Label |
|---|---|
| Docking | area:docking |
| Navigator | area:navigator |
| Ribbon | area:ribbon |
| Toolkit | area:toolkit |
| Workspace | area:workspace |
Area Extraction Process
- Template Detection: Identifies if the issue is a bug report
- Field Extraction: Searches for "Areas Affected" field using multiple regex patterns
- Content Parsing: Extracts bullet list items or single selections
- Validation: Verifies extracted areas match known area names
- Label Application: Maps areas to labels and applies them
Regex Patterns
The workflow uses multiple patterns to find the "Areas Affected" field:
const patterns = [
/###\s+Areas Affected\s*\n+([\s\S]*?)(?=\n###|$)/i,
/###\s+Areas Affected\s*([\s\S]*?)(?=\n###|$)/i,
/Areas Affected\s*\n+([\s\S]*?)(?=\n###|$)/i,
/Areas Affected\s*([\s\S]*?)(?=\n###|$)/i
];
These patterns handle various markdown formatting differences in GitHub issue forms.
Empty Field Handling
The workflow skips processing if:
- Field is empty
- Field contains "no selection"
- Field contains "none"
- Field contains "No response"
Label Deduplication
- Checks existing labels before adding new ones
- Only adds labels that aren't already present
- Prevents duplicate labels
Example Scenarios
Scenario 1: Bug Report with Single Area
Issue Body:
### Areas Affected
- Toolkit
Result:
- Title prefixed:
[Bug]: Original Title - Label added:
area:toolkit
Scenario 2: Bug Report with Multiple Areas
Issue Body:
### Areas Affected
- Toolkit
- Ribbon
- Navigator
Result:
- Labels added:
area:toolkit,area:ribbon,area:navigator
Scenario 3: Feature Request
Issue Body:
### Feature Description
Add new feature...
Result:
- Title prefixed:
[Feature Request]: Original Title - No area labels (only applies to bug reports)
Scenario 4: Issue Edit
Original Issue: No areas selected Edit: User adds "Areas Affected: Toolkit"
Result:
- Label added:
area:toolkit - Title not modified (only prefixed on open)
Error Handling
Graceful Degradation
- Title Update Failure: Logs warning but continues with label processing
- Label Addition Failure: Attempts to add labels individually
- Missing Field: Logs message and exits gracefully
- Invalid Area: Skips unknown areas
Logging
The workflow provides detailed logging:
- Pattern matching results
- Extracted areas
- Label operations
- Error messages
Configuration
No Configuration Required
This workflow requires no secrets, variables, or environment configuration. It uses the default GITHUB_TOKEN provided by GitHub Actions.
Label Requirements
The following labels must exist in the repository:
area:dockingarea:navigatorarea:ribbonarea:toolkitarea:workspace
If labels don't exist, the workflow will log warnings but continue processing.
Troubleshooting
Labels Not Applied
Possible Causes:
- Issue is not a bug report - Area labels only apply to bug reports
- "Areas Affected" field not found - Check issue body format
- Labels don't exist - Create missing labels in repository settings
- Field is empty - This is expected behavior
Solutions:
- Verify issue uses bug report template
- Check workflow logs for extraction details
- Ensure labels exist in repository
- Review issue body formatting
Title Not Prefixed
Possible Causes:
- Issue was edited, not opened - Prefixing only occurs on open
- Title already has prefix - Workflow skips if prefix exists
- Template type not detected - Check labels and issue body
Solutions:
- Prefix is only added when issue is first opened
- Manually add prefix if needed for existing issues
- Verify issue template is being used correctly
Multiple Patterns Matched
Behavior: The workflow tries patterns in order and uses the first match. This is expected and helps handle various formatting differences.
Related Workflows
- Auto-Assign PR Author: Similar automation pattern for PRs
- Build Workflow: May reference labeled issues
Code Reference
File: .github/workflows/auto-label-issue-areas.yml
Key Components:
- Event:
issueswith typesopenedandedited - Action:
actions/github-script@v8 - Logic: Regex-based field extraction and label mapping
Maintenance Notes
Adding New Areas
To add support for new areas:
Add mapping in
areaToLabelobject:'NewArea': 'area:newarea'Create the label in repository settings:
area:newareaUpdate issue template to include the new area option
Modifying Title Prefixes
To change or add title prefixes:
- Update the prefix detection logic in the script
- Modify the
titlePrefixassignment logic - Test with sample issues
Template Changes
If issue templates change:
- Update regex patterns if field names change
- Adjust detection logic for new template types
- Test extraction with new template format
Best Practices
- Keep Labels Consistent: Use the
area:*naming convention - Test Templates: Verify templates work with the workflow
- Monitor Logs: Check workflow runs for extraction issues
- Document Areas: Keep area list in sync with actual codebase structure