JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18
  • Score
    100M100P100Q52058F
  • License GNU AGPLv3

Inspired from the GitLab Triage Bot, this bot only use the GitLab API (BTA for Bot Triage Api). So there is some functionnality more difficult to do but other more simple.

Package Exports

  • gitlab-bta

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gitlab-bta) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Inspired from the GitLab Triage Bot, this bot only use the GitLab API. So there is some functionnality more difficult to do but other more simple.

If it is in the API you can use it.

Installation

To intall it, just run

npm install -g gitlab-bta

Use

# gitlab-bta --help
gitlab-bta [command]

Commands:
  gitlab-bta ./src/index  Make some automatic triage on issues and MR

Options:
  --version            Show version number                             [boolean]
  --dry-run, -n        Don't actually update anything, just print
                                                      [boolean] [default: false]
  --host-url, -H       A valid host url[string] [default: "https://gitlab.com/"]
  --token, -t          A valid API token                     [string] [required]
  --source-id, -s      GitLab project ID                     [string] [required]
  --policies-file, -f  A valid policies JS file
                                            [string] [default: "../policies.js"]
  --help, -h           Show help                                       [boolean]

Policies file

Each rule is defined in a policies.js file. Written in JS, it allows you to make some computed properties.

module.exports = {
    resource_rules: {
        merge_requests: {
            rules: [{
                name: "No Bug label",
                conditions: {
                    state: "opened",
                },
                filters: [{
                    name: "No Bug label",
                    filter: function (resource) {
                        return !resource.labels.includes("Bug");
                    },
                }],
                actions: [{
                    name: "label",
                    value: "Status: to complete",
                },{
                    name: "comment",
                    value:  "Hey @{{author.username}}, there is a problem here!",
                }],
            }],
        },
    },
};

Name

You can define a name for each rule making more obvious what the rule do.

Conditions

Conditions are the parameters used to search in the GitLab API :

conditions: {
    state: "opened", // will get only resources opened
    labels: "none", // without any label
},

Filters

You can add somme additional filters, impossible to do with the API. Those are function taking a resource as input and returning true to keep it or false to filter it.

filters: [{
    name: "Already pointed",
    filter: function (resource) {
        return !resource.labels.includes("Status: Stale");
    },
}],

Actions

In actions part, you can define some actions to do.

Label

Add a label to the resource.

actions: [{
    name: "label",
    value: "Status: Stale",
}],

Unlabel

Remove a label from a resource.

actions: [{
    name: "unlabel",
    value: "Status: Stale",
}],

Comment

Add a comment to a resource. You can use the quick actions (like /cc). You can use the resource data in the comment with mustache.

actions: [{
    name: "comment",
    value: `Hey @{{author.username}}, there is a problem here!`,
}],

Update

Update a resource. You can update all the data available in the PUT endpoint for that resource (doc for issues and doc for MRs).

actions: [{
    name: "update",
    value: {
        title: "New title",
    },
}],

Close

Close a resource

actions: [{
    name: "close",
}],