Skip to content

Warning

You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

Assign size label

Actions
Assign labels based on pull request change sizes
v0.4.2
Star (93)

size-label-action

GitHub action to assign labels based on pull request change sizes.

Labels are taken from https://github.com/kubernetes/kubernetes/labels?q=size

Usage

Create a .github/workflows/size-label.yml file:

name: size-label
on: pull_request
jobs:
  size-label:
    runs-on: ubuntu-latest
    steps:
      - name: size-label
        uses: "pascalgn/[email protected]"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Create the needed labels

Export both GITHUB_TOKEN and REPO (e.g. my-username/my-repository) and run the script below:

for size in XL XXL XS S M L; do
	curl -sf -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/kubernetes/kubernetes/labels/size/$size" |
		jq '. | { "name": .name, "color": .color, "description": .description }' |
		curl -sfXPOST -d @- -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$REPO/labels
done

Configuration

The following environment variables are supported:

  • IGNORED: A list of glob expressions separated by newlines. Files matching these expressions will not count when calculating the change size of the pull request. Lines starting with # are ignored and files matching lines starting with ! are always included.

You can configure the environment variables in the workflow file like this:

        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          IGNORED: ".*\n!.gitignore\nyarn.lock\ngenerated/**"

License

MIT

Assign size label is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Assign labels based on pull request change sizes
v0.4.2

Assign size label is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.