Today I Learned

Automate Pull Request labels via Github Actions

Imagine You want to add automatic review me label when someone makes PR to master. You can do it by using Github Actions and action named “Labeler”.
At first You have to had this specific label added to your repository.

Next, move to Github Actions tab in your repository, and create new workflow with following code:

name: Your-Labeler-name // change it before commit
      - master // destination branch where this workflow will trigger

    runs-on: ubuntu-latest

    - uses: actions/labeler@v2
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
        configuration-path: .github/Your-labeler-trigger-function-name.yml  //change it before commit

Commit this file and create new one in .github/ directory with this name (^). This file will define what changes should trigger this action and which label should be defined then. For example:

review me:
- "*"

will trigger and add review me label if any file in ROOT directory will change.

This example:

- "**"

will trigger and add bug label if any file in ANY directory will change.

Another example:

- example_directory/**/*

will trigger and apply hotfix label if any file inside example_directory or any nested directories inside it will change

If You need more informations, here’s official repository of Labeler action: