ci: add PR auto-labeler - #47
Open
hasansezertasan wants to merge 1 commit into
Open
Conversation
Add .github/workflows/pr-labeler.yml (fuxingloh/multi-labeler) plus a template-appropriate .github/labeler.yml: - type/* from the Conventional Commit PR title (feat/fix/docs/refactor/ test/ci/chore) and Breaking from a '!' bang. - area/* from changed paths (docs, src, tests, ci). - A distinguish-pr-origin job labels PRs pr/internal or pr/external + 'triage required' based on author_association (no hard-coded maintainer list, unlike the source). SHA-pinned actions, least-privilege permissions; pull_request_target is required to label fork PRs and is justified-suppressed for zizmor (no PR code is checked out). The referenced labels have been created in the repo. Adapted from #16. Closes #43
Contributor
Reviewer's GuideAdds a hardened GitHub Actions workflow that auto-labels pull requests based on conventional-commit-style titles, changed file paths, and PR author association, using a template-appropriate labeler configuration and secure permissions suitable for forked PRs. Sequence diagram for PR auto-labeling workflowsequenceDiagram
actor Contributor
participant GitHub
participant pr_labeler_workflow
participant apply_labels_job
participant multi_labeler
participant distinguish_pr_origin_job
participant github_script
participant GitHub_API
Contributor->>GitHub: open/edit/synchronize/reopen PR
GitHub->>pr_labeler_workflow: trigger pull_request_target
pr_labeler_workflow->>apply_labels_job: start job Apply labels from title and paths
apply_labels_job->>multi_labeler: fuxingloh/multi-labeler (github-token)
multi_labeler->>GitHub_API: add labels from title and files (.github/labeler.yml)
pr_labeler_workflow->>distinguish_pr_origin_job: start job Label internal vs external contributions
distinguish_pr_origin_job->>github_script: actions/github-script
github_script->>GitHub_API: read pull_request.author_association
github_script->>GitHub_API: issues.addLabels(pr/internal | pr/external + triage required)
Flow diagram for internal vs external PR origin labelingflowchart TD
A[author_association] --> B{Is association in
OWNER / MEMBER / COLLABORATOR?}
B -->|Yes| C[Set labels: pr/internal]
B -->|No| D[Set labels: pr/external,
triage required]
C --> E[github.rest.issues.addLabels]
D --> E[github.rest.issues.addLabels]
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
Breakinglabel regex only matches titles with a bang on standard type prefixes (e.g.feat!,fix!) and will miss other valid Conventional Commit types likeperforbuild!; consider broadening the pattern or documenting the expected subset of types. - Using
sync: trueon all labels means they are removed whenever titles or paths stop matching, which could surprise maintainers (e.g. manual label adjustments); consider disabling sync for labels that may be curated manually over time.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `Breaking` label regex only matches titles with a bang on standard type prefixes (e.g. `feat!`, `fix!`) and will miss other valid Conventional Commit types like `perf` or `build!`; consider broadening the pattern or documenting the expected subset of types.
- Using `sync: true` on all labels means they are removed whenever titles or paths stop matching, which could surprise maintainers (e.g. manual label adjustments); consider disabling sync for labels that may be curated manually over time.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds automatic PR labeling via
fuxingloh/multi-labelerplus a template-appropriate.github/labeler.yml. Adapted from #16, which shipped a 306-line config tailored to the litestar monorepo..github/labeler.ymltype/*from the Conventional Commit PR title:feat,fix,docs,refactor,test,ci/build,chore, plusBreakingfrom a!bang. (Pairs with ci: add PR title linting (Conventional Commits) #41's title linting.)area/*from changed paths:docs,src,tests,ci— generic to the template'ssrc/-layout structure.distinguish-pr-originjobLabels each PR
pr/internalorpr/external+triage required. Uses the PR'sauthor_association(OWNER/MEMBER/COLLABORATOR= internal) instead of #16's hard-coded maintainer list — so it needs no maintenance and works for any repo using this template.Labels
The referenced labels have been created in the repo (
type/*,area/*,Breaking,pr/internal,pr/external);triage requiredalready existed. Colors/descriptions are easy to tune.Hardening (zizmor gate, #22/#39)
multi-labeler@b15a544 # v4andgithub-script@3a2844b # v9.0.0.permissions: {}top-level; jobs get onlycontents: read+pull-requests: write/issues: write+pull-requests: write.pull_request_targetis required to label fork PRs; safe (no PR code checked out) and justified-suppressed for zizmor'sdangerous-triggers.Verified:
zizmor→ No findings (1 justified ignore).Closes
Summary by Sourcery
Introduce automated pull request labeling based on conventional commit titles, changed paths, and PR origin (internal vs external).
Build:
CI: