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@v1This is the workflow I use on all my repos: .github/workflows/labeler.yaml
Which checks out these centralized configs: https://github.com/cssnr/configs
- Keep Labels up-to-date on every workflow run.
- Use a centralized configuration local or remote file or inline JSON or YAML.
The configuration file can be remote file, local file, or inline JSON or YAML string. In all cases the same format is used.
workflows:
color: ffffff
description: Workflows modification
documentation:
color: 0075ca
description: Documentation updates
source:
color: fbca04
description: Source modificationBoth 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 URL: 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 |
| data | - | Configuration JSON/YAML 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@v1See the Examples for usage options.
This action requires the following permissions:
permissions:
issues: writePermissions documentation for Workflows and Actions.
| Output | Description of Output |
|---|---|
| changed | true if any changes or false |
| created | Labels Created JSON Array |
| updated | Labels Updated JSON Array |
| deleted | Labels Deleted JSON Array |
Note: All outputs are Strings per GitHub Spec.
- name: 'Label Creator'
id: label
uses: cssnr/label-creator-action@v1
- name: 'Echo Output'
run: |
echo "changed: ${{ steps.label.outputs.changed }}"
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.yamlWith 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.yamlWith an inline JSON string.
- name: 'Label Creator'
uses: cssnr/label-creator-action@v1
with:
data: |
{
"workflows": {"color": "ffffff", "description": "Workflows modification"},
"documentation": {"color": "0075ca", "description": "Documentation updates"},
"source": {"color": "fbca04", "description": "Source modification"}
}With an inline YAML + JSON string
- name: 'Label Creator'
uses: cssnr/label-creator-action@v1
with:
data: |
workflows: {"color": "ffffff", "description": "Workflows modification"}
source: {"color": "fbca04", "description": "Source modification"}
documentation: {"color": "0075ca", "description": "Documentation updates"}With an inline YAML string.
- name: 'Label Creator'
uses: cssnr/label-creator-action@v1
with:
data: |
workflows:
color: ffffff
description: Workflows modification
source:
color: fbca04
description: Source modification
documentation:
color: 0075ca
description: Documentation updatesFull Workflow
This is the workflow I use to pull centralized configuration files from a repository.
name: 'PR Labeler'
on:
pull_request_target:
permissions:
issues: 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.yamlNote: 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.
If you would like to submit a PR, please review the CONTRIBUTING.md.
Please consider making a donation to support the development of this project and additional open source projects.
Additionally, you can support other GitHub Actions I have published:
- Stack Deploy Action
- Portainer Stack Deploy Action
- Docker Context Action
- Actions Up Action
- VirusTotal Action
- Mirror Repository Action
- Update Version Tags Action
- Docker Tags Action
- Update JSON Value Action
- JSON Key Value Check Action
- Parse Issue Form Action
- Cloudflare Purge Cache Action
- Mozilla Addon Update Action
- Package Changelog Action
- NPM Outdated Check Action
- Label Creator Action
- Algolia Crawler Action
- Upload Release Action
- Check Build Action
- Web Request Action
- Get Commit Action
❔ Unpublished Actions
These actions are not published on the Marketplace, but may be useful.
- cssnr/create-files-action - Create various files from templates.
- cssnr/draft-release-action - Keep a draft release ready to publish.
- cssnr/env-json-action - Convert env file to json or vice versa.
- cssnr/push-artifacts-action - Sync files to a remote host with rsync.
- smashedr/update-release-notes-action - Update release notes.
- smashedr/combine-release-notes-action - Combine release notes.
📝 Template Actions
These are basic action templates that I use for creating new actions.
- js-test-action - JavaScript
- ts-test-action - TypeScript
- py-test-action - Python (Dockerfile)
- docker-test-action - Docker (Image)
Note: The docker-test-action builds, runs and pushes images to GitHub Container Registry.
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. ↩