Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivanfon/super-labeler-action
A superpowered issue and pull request labeler for Github Actions.
https://github.com/ivanfon/super-labeler-action
Last synced: 15 days ago
JSON representation
A superpowered issue and pull request labeler for Github Actions.
- Host: GitHub
- URL: https://github.com/ivanfon/super-labeler-action
- Owner: IvanFon
- License: gpl-3.0
- Created: 2020-03-14T16:24:50.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-31T20:43:32.000Z (over 1 year ago)
- Last Synced: 2024-10-26T11:36:06.816Z (21 days ago)
- Language: TypeScript
- Size: 510 KB
- Stars: 22
- Watchers: 3
- Forks: 12
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# super-labeler-action
**This action already has the features and stability for the original use case I wrote it for, and I'm not looking to add to it at this time. If you're looking for additional features, there's an active fork at [videndum/super-labeler-action](https://github.com/videndum/super-labeler-action).**
A superpowered issue and pull request labeler for Github Actions.
Super Labeler allows you to declaratively define your repository's labels, and when to apply them, in a config file that's checked into your repository.
## Getting Started
Create a new Github Actions workflow at `.github/workflows/label.yml`:
Click to show example workflow
_Note: `actions/checkout` must be run first so that the labeler action can find your config file._
```yaml
on:
issues: [opened, edited, closed, reopened]
pull_request:
types: [opened, edited, closed, reopened, ready_for_review, synchronize]jobs:
label:
runs-on: ubuntu-latest
name: Label issues and pull requests
steps:
- uses: actions/checkout@v2
- uses: IvanFon/super-labeler-action@v1
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
```Now create the labeler config file at `.github/labels.json`:
Click here to show example config
```json
{
"labels": {
"example": {
"name": "example",
"colour": "#00ff00",
"description": "Example label"
}
},
"issue": {
"example": {
"requires": 2,
"conditions": [
{
"type": "titleMatches",
"pattern": "example"
},
{
"type": "isOpen"
}
]
}
},
"pr": {
"example": {
"requires": 1,
"conditions": [
{
"type": "isDraft",
"value": false
}
]
}
}
}
```Be sure that Github Actions is enabled for in your repository's settings. Super Labeler will now run on your issues and pull requests.
## Index
- [Getting Started](#getting-started)
- [Index](#index)
- [How it Works](#how-it-works)
- [Config File Format](#config-file-format)
- [Using Regex Patterns](#using-regex-patterns)
- [Available Conditions](#available-conditions)
- [branchMatches](#branchmatches)
- [creatorMatches](#creatormatches)
- [descriptionMatches](#descriptionmatches)
- [filesMatch](#filesmatch)
- [isDraft](#isdraft)
- [isLocked](#islocked)
- [isOpen](#isopen)
- [titleMatches](#titlematches)## How it Works
Whenever Super Labeler runs, it will first add and update your repository's labels to match your config. Then it will go through each label's conditions to determine if it should apply or remove that label.
Each label has a list of conditions that must be met for it to be applied. You must specify the minimum number of conditions that must be met for the label to be applied.
Each label has a key, which can be different from it's name. This key should be in plaintext, and will be used to refer to the given label when defining your conditions. For example, given the following labels definition:
```json
{
"labels": {
"bugfix": {
"name": "Bugfix! 🎉",
"colour": "ff0000",
"description": "Fixes a bug."
}
}
}
```While the label's name, which will be displayed on Github, is "Bugfix! 🎉", to be able to easily refer to it from our conditions, we would use it's key, which is just `bugfix`:
```json
{
"pr": {
"bugfix": {
"requires": 1,
"conditions": [
{
"type": "branchMatches",
"pattern": "^bugfix"
}
]
}
}
}
```## Config File Format
The config object contains three keys:
- `labels`: Your repository's labels, which will be automatically created and updated by Super Labeler
- `issue`: Labels to apply to issues, and their conditions
- `pr`: Labels to apply to pull requests, and their conditionsTake a look at the examples in this file to get a feel for how to configure it. The below Typescript interface, which is used by this action, may also be helpful:
Click to show Typescript config interface
```js
interface Config {
labels: {
[key: string]: {
name: string,
colour: string,
description: string,
},
};
issue: {
[key: string]: {
requires: number,
conditions: IssueCondition[],
},
};
pr: {
[key: string]: {
requires: number,
conditions: PRCondition[],
},
};
}
```## Using Regex Patterns
Many conditions use regular expressions (usually with a `pattern` parameter).
Since these regular expressions are passed in through JSON strings, there are
some things to pay attention to.Special characters must be double escaped: `pattern: "\\W+$"` is equivalent to the Regex: `/\W+$/`.
If you want to use flags, use the following format: `pattern: "/^wip:/i"` is equivalent to the Regex: `/^wip:/i`.
## Available Conditions
### branchMatches
**Applies to: pull requests**
Checks if branch name matches a Regex pattern.
Example:
```json
{
"type": "branchMatches",
"pattern": "^bugfix\\/"
}
```### creatorMatches
**Applies to: issues and pull requests**
Checks if an issue or pull request's creator's username matches a Regex pattern.
Example:
```json
{
"type": "creatorMatches",
"pattern": "^foo"
}
```### descriptionMatches
**Applies to: issues and pull requests**
Checks if an issue or pull request's description matches a Regex pattern.
Example:
```json
{
"type": "descriptionMatches",
"pattern": "foo.*bar"
}
```### filesMatch
**Applies to: pull requests**
Checks if the files modified in the pull request match a glob.
Globs are matched using the [minimatch](https://github.com/isaacs/minimatch) library.
Example:
```json
{
"type": "filesMatch",
"glob": "src/foo/**/*"
}
```### isDraft
**Applies to: pull requests**
Checks if a pull request is a draft.
Example:
```json
{
"type": "isDraft",
"value": true
}
```### isLocked
**Applies to: issues and pull requests**
Checks if an issue or pull request is locked.
Example:
```json
{
"type": "isLocked",
"value": true
}
```### isOpen
**Applies to: issues and pull requests**
Checks if an issue or pull request is open or closed.
Example:
```json
{
"type": "isOpen",
"value": true
}
```### titleMatches
**Applies to: issues and pull requests**
Checks if an issue or pull request's title matches a Regex pattern.
Example:
```json
{
"type": "titleMatches",
"pattern": "/^wip:/i"
}
```---
[back to top](#super-labeler-action)