Skip to content

v5.0.0-alpha.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@MaksimZhukov MaksimZhukov released this 24 May 11:53
4f05277

What's Changed

This alpha release introduces the following major changes:

  1. Fix the bug related to the sync-labels input. Now the input value is read correctly. #480
  2. Add the ability to apply labels based on base and/or head branch names. #203
  3. Change the behavior of the any selector to match ANY file against ANY glob pattern.

This is an alpha version and we would appreciate it if you could provide us with your feedback. If you have any questions, ideas or concerns, please share them in the corresponding issue.

Usage

The match object allows you to control the matching options. You can specify the label to be applied based on the changed files and/or the name of the base or head branch. For the changed files, you have to provide a path glob, and for the branches, you have to provide a regexp to match against the branch name.

Please note that the structure of the configuration file (.github/labeler.yml) has been changed! There are two top-level keys: any and all, that accept the same configuration options:

LabelName:
- any:
  - changed-files: ['list', 'of', 'globs']
  - base-branch: ['list', 'of', 'regexps']
  - head-branch: ['list', 'of', 'regexps']
- all:
  - changed-files: ['list', 'of', 'globs']
  - base-branch: ['list', 'of', 'regexps']
  - head-branch: ['list', 'of', 'regexps']

How do the any and all keys work?

  1. all: all of the provided options (changed-files, base-branch, etc.) must match for the label to be applied. ALL globs or regexps must match against branch names or ALL changed files.
  2. any: any of the provided options (changed-files, base-branch, etc.) must match for the label to be applied. ANY globs or regexps must match against branch names or ANY changed files.

Note: The behavior of the any selector for changed files has been changed to match ANY file against ANY glob pattern.

# Add the `frontend` label to any change to any *.js files as long as the `main.js` hasn't been changed and the PR is open against the `main` branch
frontend:
- any:
  - changed-files: ['src/**/*.js']
- all:
  - changed-files: ['!src/main.js']
  - base-branch: 'main'

If an option is specified without a top-level key, it will default to any. In particular, the following two configurations are equivalent:

LabelName:
- changed-files: src/*

and

LabelName:
- any:
  - changed-files: ['src/*']

More examples

  1. Add the feature label to any PR where the head branch name starts with feature or has feature in the name
feature:
- head-branch: ['^feature', 'feature']
  1. Add the release label to any PR that is open against the main branch
release:
- base-branch: 'main'
  1. Add the test label to any PR that is open against the main branch and the head branch name starts with feature
test:
- all:
  - base-branch: 'main'
  - head-branch: '^feature'
  1. Add the test label if there are any changes in the *.js files within the source directory or within the __tests__ directory, or the head branch name starts with example
test:
- any:
  - changed-files: ['__tests__/**/*.js', 'src/**/*.js']
  - head-branch: '^example'

New Contributors