Code Monkey home page Code Monkey logo

pull-request-labeler-action's Introduction

Result illustration


This repository provides a GitHub action to automatically label a pull request based on committed files.

Table of Contents

Common usage

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

Breaking change

Starting from August 2019, GitHub switch Actions syntax from HCL to YAML. The previous syntax will no longer be supported by GitHub on September 30, 2019.

As a consequence, please use v2.0.0+ release and note that all v1.x.x are deprecated and will no longer work on September 30, 2019.

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

Settings for v1.0.0+ release (deprecated)

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/[email protected]"
  secrets = ["GITHUB_TOKEN"]
}

Settings for v2.0.0+ release

Create a file into your root project directory: .github/workflows/labeler.yml:

# Workflow to associate labels automatically
name: labeler
# Trigger the workflow on pull request events
on: [pull_request]
jobs:
  label:
    runs-on: ubuntu-18.04
    steps:
      # We need to checkout the repository to access the configured file (.github/label-pr.yml)
      - uses: actions/checkout@v2
      - name: Labeler
        uses: docker://decathlon/pull-request-labeler-action:2.0.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Here we can override the path for the action configuration. If none is provided, default one is `.github/label-pr.yml`
          CONFIG_PATH: ${{ secrets.GITHUB_WORKSPACE }}/.github/label-pr.yml

Please note that you can move the label-pr.yml to another location, if so, then do not forget to update the above CONFIG_PATH variable.

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

pull-request-labeler-action's People

Contributors

lusoalex avatar mmornati avatar gep13 avatar rdelgatte avatar hisasann avatar fossabot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.