Automatically Create or Update Labels to ensure they exist and are synchronized. Works from a centralized remote configuration file/url, local file or inline config.
This works by fetching the configuration file and current repository labels.
It loops through the configuration and checks if the provided labels exist.
If the label does not exist, it creates a new label with the name, color and description.
If the label exist, it makes sure the color and description matches, otherwise updates them.
You can also enable delete
which will delete any labels not in the configuration file.
- name: 'Label Creator'
uses: cssnr/label-creator-action@v1
- Keep Labels up-to-date on every workflow run.
- Use a centralized configuration local or remote file, or inline JSON.
The configuration file can be remote file, local file, or inline JSON string. In all cases the same format is used.
source:
color: fbca04
description: Source modification
documentation:
color: 0075ca
description: Documentation updates
Both color
and description
are optional; however, I assume you are using this action because you want to set one of them.
If you are using actions/labeler it will create the labels, but not set the description or color.
By default, the file is sourced from .github/labels.yaml
but can be placed anywhere.
This includes remote files.
Example: https://raw.githubusercontent.com/cssnr/label-creator-action/refs/heads/master/.github/labels.yaml
All inputs are optional.
Input | Default Value | Description of Input |
---|---|---|
file | .github/labels.yaml |
Configuration file path |
url | - | Configuration file URL |
json | - | Configuration JSON string |
delete | false |
Delete labels not in config |
summary | true |
Add Summary to Job |
dry-run | false |
Dry Run, only output results |
token | ${{ github.token }} |
GitHub Access Token PAT 1 |
This action is designed to work on the pull_request_target
trigger.
Example workflow: .github/workflows/labeler.yaml
- name: 'Label Creator'
uses: cssnr/label-creator-action@v1
See the Examples for usage options.
This action requires the following permissions:
permissions:
pull-requests: write
Permissions documentation for Workflows and Actions.
Output | Description |
---|---|
created | Labels Created |
updated | Labels Updated |
deleted | Labels Deleted |
Note: These are JSON Arrays.
- name: 'Label Creator'
id: label
uses: cssnr/label-creator-action@v1
- name: 'Echo Output'
run: |
echo "created: ${{ steps.label.outputs.created }}"
echo "updated: ${{ steps.label.outputs.updated }}"
echo "deleted: ${{ steps.label.outputs.deleted }}"
💡 Click on an example heading to expand or collapse the example.
With a local file.
- name: 'Label Creator'
uses: cssnr/label-creator-action@v1
with:
file: .github/labels.yaml
With a remote file.
- name: 'Label Creator'
uses: cssnr/label-creator-action@v1
with:
url: https://raw.githubusercontent.com/cssnr/label-creator-action/refs/heads/master/.github/labels.yaml
With an inline JSON string.
- name: 'Label Creator'
uses: cssnr/label-creator-action@v1
with:
json: |
{
"workflows": {"color": "ffffff", "description": "Workflows modification"},
"documentation": {"color": "0075ca", "description": "Documentation updates"},
"source": {"color": "fbca04", "description": "Source modification"}
}
Full Workflow
This is the workflow I use to pull centralized configuration files from a repository.
name: 'PR Labeler'
on:
pull_request_target:
permissions:
pull-requests: write
jobs:
labeler:
name: 'Labeler'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: 'Checkout Configs'
uses: actions/checkout@v4
with:
repository: cssnr/configs
ref: master
path: .configs
sparse-checkout-cone-mode: false
sparse-checkout: |
labels/**
- name: 'Debug'
continue-on-error: true
run: |
echo "::group::labels.yaml"
cat .configs/labels/labels.yaml
echo "::endgroup::"
echo "::group::labeler.yaml"
cat .configs/labels/labeler.yaml
echo "::endgroup::"
- name: 'Label Creator'
continue-on-error: true
uses: cssnr/label-creator-action@v1
with:
file: .configs/labels/labels.yaml
- name: 'Labeler'
uses: actions/labeler@v6
with:
sync-labels: true
configuration-path: .configs/labels/labeler.yaml
Note: Steps with continue-on-error: true
will fail silently.
For more examples, you can check out other projects using this action:
https://github.com/cssnr/label-creator-action/network/dependents
The following rolling tags are maintained.
Version Tag | Rolling | Bugs | Feat. | Name | Target | Example |
---|---|---|---|---|---|---|
✅ | ✅ | ✅ | Major | vN.x.x |
vN |
|
✅ | ✅ | ❌ | Minor | vN.N.x |
vN.N |
|
❌ | ❌ | ❌ | Micro | vN.N.N |
vN.N.N |
You can view the release notes for each version on the releases page.
The Major tag is recommended. It is the most up-to-date and always backwards compatible. Breaking changes would result in a Major version bump. At a minimum you should use a Minor tag.
For general help or to request a feature, see:
- Q&A Discussion: https://github.com/cssnr/label-creator-action/discussions/categories/q-a
- Request a Feature: https://github.com/cssnr/label-creator-action/discussions/categories/feature-requests
If you are experiencing an issue/bug or getting unexpected results, you can:
- Report an Issue: https://github.com/cssnr/label-creator-action/issues
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
- Provide General Feedback: https://cssnr.github.io/feedback/
For more information, see the CSSNR SUPPORT.md.
Please consider making a donation to support the development of this project and additional open source projects.
If you would like to submit a PR, please review the CONTRIBUTING.md.
Additionally, you can support other GitHub Actions I have published:
- Stack Deploy Action
- Portainer Stack Deploy
- VirusTotal Action
- Mirror Repository Action
- Update Version Tags Action
- Update JSON Value Action
- Parse Issue Form Action
- Cloudflare Purge Cache Action
- Mozilla Addon Update Action
- Docker Tags Action
- Package Changelog Action
- NPM Outdated Check Action
- Label Creator Action
- Algolia Crawler Action
- Upload Release Action
For a full list of current projects visit: https://cssnr.github.io/
Footnotes
-
The
${{ github.token }}
/{{ secrets.GITHUB_TOKEN }}
is automatically passed, there is no need to manually pass these! This is only available to allow users to pass a different token they have created and defined in theirsecrets
. ↩