Skip to content
Latchkey

How to Add Size Labels (XS/S/M/L) to Pull Requests

A size-label action counts additions plus deletions and applies a bucketed label like size/S or size/XL.

Run pascalgn/size-label-action on pull_request events. It computes the diff size and applies a size/* label, and you can override the thresholds with an env var.

Steps

  • Add a workflow triggered on pull_request.
  • Run pascalgn/size-label-action with GITHUB_TOKEN.
  • Optionally set IGNORED and custom size thresholds via sizes.

Workflow

.github/workflows/ci.yml
on: [pull_request]
permissions:
  pull-requests: write
jobs:
  size:
    runs-on: ubuntu-latest
    steps:
      - uses: pascalgn/size-label-action@v0.5.4
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          sizes: >
            {
              "0": "XS",
              "20": "S",
              "100": "M",
              "500": "L",
              "1000": "XL"
            }

Gotchas

  • Exclude generated files with an IGNORED env var so lockfiles do not inflate the size.
  • The label updates on each push, so a shrinking PR moves back down a bucket.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →