generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
Describe the feature
Add a GitHub Actions workflow that runs on incoming pull requests and automatically applies labels based on configurable rules (e.g. files changed, branch name, PR title, or draft status).
Examples of desired behavior:
- PRs that touch only
docs/**get a label likedocumentation. - PRs that add a new directory under
plugins/get thenew-pluginlabel (required by MAINTAINERS_GUIDE). - PRs that only change workflow files get a label like
ciorworkflows. - Optionally: draft PRs get a
draftlabel; or PRs from first-time contributors get afirst-time-contributorlabel.
The exact rules can be decided during implementation, but the workflow should be the single place that performs automatic labeling so maintainers don’t have to remember to add labels manually.
Use Case
- Consistency: The maintainers guide says new-plugin PRs must have the
new-pluginlabel. Today that’s manual; it’s easy to forget and then merge checks or triage can be wrong. - Triage and filtering: Labels like
documentation,ci,new-pluginhelp with filtering (e.g. “PRs needing review” by area) and with automation (e.g. routing, stale bot). - Less manual work: Automatically applying obvious labels from changed paths or PR metadata reduces maintainer toil.
Proposed Solution
-
New workflow file
- Add
.github/workflows/label-pr.yml(or similar) that triggers onpull_request(opened, synchronize, or reopened) withcontents: readandpull-requests: write(orissues: writeif using issue labels) so it can add labels.
- Add
-
Labeling logic
- Option A: Use an existing action (e.g.
actions/labeler,dorny/pull-request-labeler) that supports path-based rules defined in a config file (e.g..github/labeler.ymlor.github/pr-labels.yml). Configure rules such as:plugins/*(new or modified underplugins/) →new-pluginonly when a new plugin directory is added (may require custom logic or a second action).docs/**→documentation.github/workflows/**→ci
- Option B: A small composite or script step that uses the GitHub API (or
gh pr edit) to add labels based ongithub.event.pull_request.changed_filesorgit diffand a small rule set.
- Option A: Use an existing action (e.g.
-
Documentation
- Document the workflow and the label rules in the repo (e.g. MAINTAINERS_GUIDE or a short section in DEVELOPMENT_GUIDE or a dedicated
.github/labeler.md).
- Document the workflow and the label rules in the repo (e.g. MAINTAINERS_GUIDE or a short section in DEVELOPMENT_GUIDE or a dedicated
-
Safety
- Prefer idempotent behavior (don’t fail the workflow if a label already exists). Avoid overwriting or removing labels that maintainers added manually unless that’s an explicit goal.
Other Information
- MAINTAINERS_GUIDE already requires the
new-pluginlabel for PRs that add a new plugin directory; this workflow would enforce or assist that. - If using a third-party action, prefer one that is maintained and has a clear license; pin by SHA for security.
- Consider whether to label only on
pull_request.openedor also onsynchronizeso labels stay correct when the PR base or files change.
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
Reactions are currently unavailable