Automatically label your Pull Requests with size indicators -- XS, S, M, L, XL -- based on the total number of lines changed.
Helps teams quickly triage PRs, encourage smaller changes, and keep code review manageable.
When a Pull Request is opened or updated, this action:
- Fetches the PR diff stats (additions + deletions).
- Calculates the total number of changed lines.
- Applies a
size/*label based on configurable thresholds. - Removes any previously applied size label so only one is present at a time.
- Posts (or updates) a comment with a breakdown of the changes.
| Label | Changed lines |
|---|---|
size/XS |
0 -- 10 |
size/S |
11 -- 50 |
size/M |
51 -- 200 |
size/L |
201 -- 500 |
size/XL |
501+ |
Labels are created automatically in your repository with a color gradient from green (XS) to red (XL).
Add the following workflow file to your repository at .github/workflows/pr-size.yml:
name: PR Size Labeler
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: tatelyman/pr-size-labeler@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }} - uses: tatelyman/pr-size-labeler@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
xs_max: "5"
s_max: "25"
m_max: "100"
l_max: "300"| Input | Description | Required | Default |
|---|---|---|---|
github_token |
GitHub token for API access | Yes | -- |
xs_max |
Max changed lines for XS | No | 10 |
s_max |
Max changed lines for S | No | 50 |
m_max |
Max changed lines for M | No | 200 |
l_max |
Max changed lines for L | No | 500 |
Anything above l_max is labeled XL.
| Output | Description |
|---|---|
label |
The size label that was applied (e.g. size/M) |
total_changes |
Total number of changed lines |
additions |
Number of added lines |
deletions |
Number of deleted lines |
When the action runs, it posts a comment like this:
size/M Pull Request
Metric Count Additions +120 Deletions -45 Total changes 165
The action creates color-coded labels automatically:
size/XS-- greensize/S-- yellow-greensize/M-- yellowsize/L-- orangesize/XL-- red
The action needs the following permissions:
pull-requests: write-- to add labels and post commentscontents: read-- to access PR diff stats
These are configured in the workflow YAML as shown in the usage example above.
MIT
If you find this useful, consider supporting the project:
SOL Wallet: NaTTUfDDQ8U1RBqb9q5rz6vJ22cWrrT5UAsXuxnb2Wr
- DevTools.run — Free developer tools
- @solscanitbot — Solana trading bot on Telegram
- GitHub Sponsors