GitHunt
SA

samspills/pull-request-labeler-action

:zap: Github action to label your pull requests auto-magically :sparkles:(using committed files)

Github auto-labeler action

FOSSA Status
CircleCI

GitHub actions to auto label a pull request based on committed files.

Result illustration

When pushing, the action will be triggered and will look for committed files over your branch.
It applies configured labels whenever it find a file whose name matches the associated regular expression.

Expected result after processing Action log messages

Startup

Configuration

Create a file into your root project directory: .github/label-pr.yml:

- regExp: ".*\\.ts+$"
  labels: ["typescript"]
- regExp: ".*\\.sql+$"
  labels: ["database", "critical"]
- regExp: ".*\\.md+$"
  labels: ["documentation"]
- regExp: "^(pom\\.xml|package\\.json|build\\.gradle)$"
  labels: ["dependencies"]
- regExp: ".*\\.(zip|jar|war|ear)+$"
  labels: ["artifact", "invalid"]

This is a sample to illustrate how you can customize your settings by configuring your own regex and labels

The configuration is made of a list of Filter which are composed of:

  • regExp: a regular expression which will be tested over the filenames
  • labels: a list of labels to apply if the filenames match

If the labels do not exist yet in your repository configuration, they will be created anyway.

Use Github action

Create a file into your root project directory (if it does not exist yet): .github/main.workflow:

workflow "New workflow" {
  resolves = ["PR label by Files"]
  on = "pull_request"
}

action "PR label by Files" {
  uses = "decathlon/pull-request-labeler-action@v1.0.0"
  secrets = ["GITHUB_TOKEN"]
}

When configuring the action, you need to provide the right link into uses field here.

Contributing

  • The project is built using Typescript # 3.5.2
  • We use a tslint as a linter for defining code style which configuration may change
  • We use Jest as the testing framework

To start, you just need to clone the repository and open it in your favorite IDE.
You may need to set it up so it uses the node configuration (package.json) and tslint configuration (tslint.json).

Commands

  • To run unit tests: npm run test:watch
  • To build: npm run build:main

License

FOSSA Status

Languages

TypeScript82.8%Dockerfile7.5%HCL6.1%JavaScript3.5%

Contributors

Apache License 2.0
Created August 22, 2019
Updated August 22, 2019