|
12 | 12 | [](https://goreportcard.com/report/github.com/agilepathway/label-checker)
|
13 | 13 | [](https://golang.org/)
|
14 | 14 |
|
15 |
| -[GitHub Action](https://github.com/features/actions) to check pull requests for the presence or absence of specified labels |
| 15 | + **[GitHub Action](https://github.com/features/actions) to check pull requests (PRs) for the presence or absence of specified labels** |
| 16 | + |
| 17 | +## Using the Label Checker action |
| 18 | + |
| 19 | +Using this action is as simple as: |
| 20 | + |
| 21 | +1. **create a `.github\workflows` directory** in your repository |
| 22 | +2. **create a |
| 23 | + [YAML](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#about-yaml-syntax-for-workflows) |
| 24 | + file** in the `.github\workflows` directory (file name can be anything you like, |
| 25 | + with either a `.yml` or `.yaml` file extension), with this example content: |
| 26 | + |
| 27 | + ``` |
| 28 | + --- |
| 29 | + name: Label Checker |
| 30 | + on: |
| 31 | + pull_request: |
| 32 | + types: |
| 33 | + - opened |
| 34 | + - synchronize |
| 35 | + - reopened |
| 36 | + - labeled |
| 37 | + - unlabeled |
| 38 | + |
| 39 | + jobs: |
| 40 | + |
| 41 | + check_labels: |
| 42 | + name: Check labels |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - uses: docker://agilepathway/pull-request-label-checker:latest |
| 46 | + with: |
| 47 | + one_of: major,minor,patch |
| 48 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + ``` |
| 50 | + |
| 51 | +4. **customise the label checks** in the `with` section of the YAML file to fit your needs |
| 52 | + |
| 53 | + (see the [checks](#checks) section below for the different checks you can configure) |
| 54 | + |
| 55 | + |
| 56 | +## Checks |
| 57 | + |
| 58 | +There are 4 types of label checks available: |
| 59 | + |
| 60 | +- `one_of` (PRs must have **exactly one** of these labels) |
| 61 | + |
| 62 | +- `none_of` (PRs must have **none** of these labels) |
| 63 | + |
| 64 | +- `all_of` (PRs must have **all** of these labels) |
| 65 | + |
| 66 | +- `any_of` (PRs must have **one or more** of these labels) |
| 67 | + |
| 68 | +You can have as many of the checks configured in the same YAML file as you like. |
| 69 | + |
| 70 | +### Examples |
| 71 | + |
| 72 | +- [Semantic versioning](https://semver.org/): `one_of: major,minor,patch` |
| 73 | + |
| 74 | +- Each PR must be a bug or an enhancement: `one_of: bug,enhancement` |
| 75 | + |
| 76 | +- Prohibit certain labels: `none_of: invalid,wontfix,duplicate,question` |
| 77 | + |
| 78 | +- Require each PR to have a certain label: `all_of: enhancement` |
| 79 | + |
| 80 | + or labels: `all_of: enhancement,reviewed` |
| 81 | + |
| 82 | +- Require each PR to have one or more of these labels: `any_of: documentation,enhancement,bug` |
| 83 | + |
| 84 | +- Combine multiple checks: |
| 85 | + |
| 86 | + ``` |
| 87 | + with: |
| 88 | + one_of: major,minor,patch |
| 89 | + none_of: invalid,wontfix,duplicate,question |
| 90 | + any_of: documentation,enhancement,bug |
| 91 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + ``` |
| 93 | + |
| 94 | +- Combine multiple checks of the same type: |
| 95 | + |
| 96 | + ``` |
| 97 | + jobs: |
| 98 | + |
| 99 | + check_semver_label: |
| 100 | + name: Check for semantic version label |
| 101 | + runs-on: ubuntu-latest |
| 102 | + steps: |
| 103 | + - uses: docker://agilepathway/pull-request-label-checker:latest |
| 104 | + with: |
| 105 | + one_of: major,minor,patch |
| 106 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 107 | +
|
| 108 | + check_pull_request_type: |
| 109 | + name: Check for pull request type label |
| 110 | + runs-on: ubuntu-latest |
| 111 | + steps: |
| 112 | + - uses: docker://agilepathway/pull-request-label-checker:latest |
| 113 | + with: |
| 114 | + one_of: one_of: bug,enhancement |
| 115 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + ``` |
| 117 | + |
| 118 | + |
| 119 | +## Suggestions / bug reports |
| 120 | + |
| 121 | +[Suggestions and bug reports](https://github.com/agilepathway/label-checker/issues) |
| 122 | +are very welcome :slightly_smiling_face: |
| 123 | + |
| 124 | +## Why another label checker? |
| 125 | + |
| 126 | +- We couldn't find another label checker that had all the 4 check types available |
| 127 | + |
| 128 | +- Speed: the [Docker image](https://hub.docker.com/repository/docker/agilepathway/pull-request-label-checker) |
| 129 | + used for the checks is only 2.7 MB, so the checks are blazingly fast (c. 3 seconds) |
0 commit comments