Conversation
77bb3c8 to
b1476e1
Compare
There was a problem hiding this comment.
Pull request overview
Adds repository automation to standardize labels and automatically apply them to PRs (by changed paths) and Issues (by keyword matching), with optional backfill for existing open items.
Changes:
- Introduces an
Auto LabelGitHub Actions workflow that ensures a baseline label set exists, then applies labels to PRs/issues and supports manual backfill viaworkflow_dispatch. - Adds
.github/labeler.ymlpath-to-label rules to drive PR labeling.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.github/workflows/auto-label.yml |
Creates/updates repo labels, labels PRs via actions/labeler, labels issues via keyword rules, and provides backfill jobs for open PRs/issues. |
.github/labeler.yml |
Defines file-path glob rules mapping changes to area:* labels for PR auto-labeling. |
Comments suppressed due to low confidence (2)
.github/workflows/auto-label.yml:24
- Workflow-level permissions grant
pull-requests: writefor all triggers (includingissuesandworkflow_dispatch). For least-privilege, consider moving permissions to per-job blocks (e.g.,ensure-labels/issue-keyword-labelsonly needissues: write, whilepr-path-labelsneedsissues: write+ minimal PR/content read as required).
permissions:
contents: read
issues: write
pull-requests: write
.github/workflows/auto-label.yml:156
- With
sync-labels: true, the labeler will remove config-managed labels when patterns stop matching (e.g., after a PR update), which also removes any manual overrides for those same labels on subsequentsynchronizeevents. If you want to allow maintainers to manually keep anarea:label even when patterns no longer match, consider settingsync-labels: falseor limiting which labels are synced.
- name: Apply labels from changed paths
uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml
sync-labels: true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const managedLabels = [ | ||
| "bug", | ||
| "feature", | ||
| "documentation", | ||
| "question", | ||
| "security", | ||
| "kind: bug", | ||
| "kind: feature", | ||
| "kind: documentation", | ||
| "kind: question", | ||
| "kind: security", | ||
| ]; |
There was a problem hiding this comment.
managedLabels includes kind: ... labels, but this workflow never adds those labels to expected and ensure-labels doesn't create them. Consider removing the kind: entries or adding corresponding label creation + rules so the managed set matches what the workflow actually applies.
| @@ -169,7 +192,7 @@ jobs: | |||
| ], | |||
| }, | |||
| { | |||
| label: "kind: bug", | |||
| label: "bug", | |||
There was a problem hiding this comment.
The issue-keyword labeling rules are duplicated in the backfill-open-issues job below. To avoid drift (e.g., updating patterns in one place but not the other), consider extracting the rules/managed label list into a single source (separate JS file in repo, or a reusable composite action) and reusing it in both jobs.
| def load_label_patterns(): | ||
| mapping = {} | ||
| current_label = None | ||
| with open(".github/labeler.yml", "r", encoding="utf-8") as handle: | ||
| for raw_line in handle: | ||
| stripped = raw_line.strip() | ||
| if not stripped or stripped.startswith("#"): | ||
| continue | ||
| if stripped.startswith('"') and stripped.endswith('":'): | ||
| current_label = stripped[:-1].strip('"') | ||
| mapping[current_label] = [] | ||
| continue | ||
| if stripped.startswith('- "') and current_label: | ||
| mapping[current_label].append(stripped[3:-1]) | ||
| return mapping |
There was a problem hiding this comment.
This YAML parsing in load_label_patterns() is format-dependent (requires quoted label keys and quoted glob lines) and will silently break if .github/labeler.yml is reformatted or expanded (e.g., unquoted keys, additional list items). Consider using a real YAML parser, or at least relaxing the heuristics to handle unquoted keys and unquoted glob entries so backfill stays aligned with the labeler config.
| const managedLabels = [ | ||
| "bug", | ||
| "feature", | ||
| "documentation", | ||
| "question", | ||
| "security", | ||
| "kind: bug", | ||
| "kind: feature", | ||
| "kind: documentation", | ||
| "kind: question", | ||
| "kind: security", | ||
| ]; |
There was a problem hiding this comment.
Same as above: managedLabels includes kind: labels that aren't created by ensure-labels and aren't produced by the rules in this job. Align the managed list with the labels the workflow can actually apply (or add kind: label creation + keyword rules).
No description provided.