0.1.5 • Published 11 months ago

gitlab-labeler v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Gitlab Labeler

A simple cli tool that automatically labels merge requests in your GitLab repository.

Installation

To install the Gitlab Labeler, run the following command in your project directory:

npm install --save-dev gitlab-labeler

Usage

You can easily define label-directory Matches by creating file namedlabeler.config.jsin your project directory with the following Content:

module.exports = {
  directoriesLabels: [
    {
      regExp: "path/to/your/directoryg",
      labels: ["your-label"],
    },
    // Add more directory-label pairs as needed
  ],
};

To run

npx gitlab-labeler

Configuration

Its also possible to define Env Variables, which are always priorized and overwrite config Properties from the File. Env variables are always prefixed LABELER_ and in SNAKE_CASE.

Here is an overview of all possible Configurations:

Env VariableConfig PropertydefaultDescription
LABELER_ACCESS_TOKEN//(required) Access Token for Gitlab-Api access.
LABELER_DIRECTORIES_LABELSdirectoriesLabels[]n array of objects that define the mapping between directories and labels. Each object contains a regular expression (regExp) and an array of labels (labels).
LABELER_WRITE_COMMENTwriteCommenttrueA boolean value that determines whether a comment should be written to the merge request in GitLab.
LABELER_DETECT_CHANGESdetectChangesgitlab-apiA string value that specifies the method used to detect changes in the merge request. It can be set to "gitlab-api" or "local-git".

NOTE: This script is made to be run in CI Context of Gitlab. It consumes some Gitlab predefined Variables for Merge Requests and won't run without these. To test locally you have to define CI_SERVER_HOST, CI_SERVER_PROTOCOL, CI_MERGE_REQUEST_TARGET_BRANCH_NAME, CI_MERGE_REQUEST_PROJECT_ID, CI_MERGE_REQUEST_IID on your own.

License

This project is licensed under the MIT License. See the LICENSE.md file for more information.

0.1.5

11 months ago

0.1.4

11 months ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago