GitHub Action
PR Labels Check
This GitHub Action is created to validate pull requests based on predefined labels.
By specifying valid and/or invalid labels, this action ensures that pull requests are labeled consistently according to your project standards. If a pull request does not contain at least one valid label or if it contains any invalid labels, the action will fail and providing clear error messages.
- Label Validation: Ensures that a pull request has at least one valid label and no invalid labels.
- Detailed Error Messages: Provides clear error messages when no valid labels are found or when invalid labels are detected, causing the action to fail.
- Easy Configuration: Labels can be easily configured through the action's input parameters.
The following input parameters can be used to configure the action:
The GitHub token used to interact with the GitHub API.
- Default:
${{ github.token }}
- Usage: Optional
The number of the pull request to validate.
- Default:
${{ github.event.pull_request.number }}
- Usage: Optional
A comma-separated list of valid labels that are allowed on the pull request.
- Default: None
- Usage: Required
A comma-separated list of invalid labels that are not allowed on the pull request.
- Default: None
- Usage: Optional
None. This action does not set any outputs.
This example workflows demonstrates a minimal configuration to validate pull requests based on predefined labels. In this example, the action is configured to check for valid labels breaking-change
, bugfix
, documentation
, and enhancement
.
name: PR Labels
on:
pull_request_target:
types: [opened, labeled, unlabeled, synchronize]
jobs:
validate:
name: Verify
runs-on: ubuntu-latest
steps:
- name: 🏷 Verify PR has a valid label
uses: klaasnicolaas/action-pr-labels@v1
with:
valid-labels: >-
breaking-change, bugfix, documentation, enhancement
This example workflow demonstrates a full example configuration to validate pull requests based on predefined labels. In this example, the action is configured to check for valid labels breaking-change
, bugfix
, documentation
, and enhancement
. Additionally, it checks for invalid labels duplicate
and invalid
.
name: PR Labels
on:
pull_request_target:
types: [opened, labeled, unlabeled, synchronize]
jobs:
validate:
name: Verify
runs-on: ubuntu-latest
steps:
- name: 🏷 Verify PR has a valid label
uses: klaasnicolaas/action-pr-labels@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ github.event.pull_request.number }}
valid-labels: >-
breaking-change, bugfix, documentation, enhancement
invalid-labels: >-
duplicate, invalid
This is an active open-source project. We are always open to people who want to use the code or contribute to it.
We've set up a separate document for our contribution guidelines.
Thank you for being involved! 😍
Distributed under the Apache License 2.0 license. See LICENSE
for more information.