GitHub Action to manage labels on GitHub (create/rename/update/delete) as code.
In the repository where you want to perform this action, create the YAML file
.github/labels.yml
(you can also set a custom filename) that
looks like:
- name: "bug"
color: "#d73a4a"
description: "Something isn't working"
- name: "documentation"
color: "#0075ca"
description: "Improvements or additions to documentation"
- name: "duplicate"
color: "#cfd8d7"
description: "This issue or pull request already exists"
- name: "enhancement"
color: "#a22eef"
- name: "wontfix_it"
color: "#000000"
description: "This will not be worked on"
from_name: "wontfix"
name
, color
and description
are the main GitHub label fieldsdescription
can be omit if your want to keep the current onefrom_name
allow to rename a label from one currently available on your repositoryname: github
on:
push:
branches:
- 'main'
paths:
- '.github/labels.yml'
- '.github/workflows/labels.yml'
pull_request:
paths:
- '.github/labels.yml'
- '.github/workflows/labels.yml'
jobs:
labeler:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
dry-run: ${{ github.event_name == 'pull_request' }}
exclude: |
help*
*issue
With this workflow, the YAML configuration above on a fresh repository, this will:
bug
(because same color
and description
)documentation
(because same color
and description
)duplicate
(color
is different)enhancement
(color
is different, keep current description
)good first issue
alone (because it matches an exclude
pattern)help wanted
alone (because it matches an exclude
pattern)invalid
question
wontfix
to wontfix_it
and set color
and description
Following inputs can be used as step.with
keys
Name | Type | Description |
---|---|---|
yaml-file |
String | Path to YAML file containing labels definitions. (default .github/labels.yml ) |
skip-delete |
Bool | If enabled, labels will not be deleted if not found in YAML file. (default false ) |
dry-run |
Bool | If enabled, changes will not be applied. (default false ) |
exclude |
List | Newline delimited list of labels pattern(s)/matcher to exclude |
Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. You can also support this project by becoming a sponsor on GitHub or by making a PayPal donation to ensure this journey continues indefinitely!
Thanks again for your support, it is much appreciated! :pray:
MIT. See LICENSE
for more details.