CLI that sets GitHub labels exactly as written in YAML file
- Create a label (e.g. when no label described in YAML)
- Edit a label (e.g. when its color was changed)
- Delete a label (e.g. when the label not described in YAML exists on GitHub)
labels:
- name: kind/proactivedescription: Categorizes issue or PR as related to proactive tasks.color: 9CCC65
- name: kind/reactivedescription: Categorizes issue or PR as related to reactive tasks.color: FFA000repos:
- name: org/repolabels:
- kind/proactive
- kind/reactiveYou can put this file to anywhere as you like. It defaults to .github/labels.yml. This is the config file to define the labels. Basically it means GitHub labels are configured as this file defines.
.github/labels.yml
labels:
- name: help wanteddescription: Extra attention is neededcolor: "008672"
- name: bugdescription: Something isn't workingcolor: fc2929
- name: enhancementdescription: New feature or requestcolor: 84b6eb
- name: questiondescription: Further information is requestedcolor: cc317crepos:
- name: user/repolabels:
- help wanted
- bug
- enhancement
- questionThis is the one of the workflow of this app. It means to do the same with GitHub Actions as running github-labeler on your local machine.
.github/workflows/sync_labels.yml
name: Sync labelson:
push:
branches:
- masterpaths:
- .github/labels.ymljobs:
sync:
name: Runruns-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@1.0.0
- name: Sync labelsuses: b4b4r07/github-labeler@masterenv:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}If you want to make sure what changes to be applied in a pull request step, you can run github-labeler with dryrun option. By having action-github-comment step, you can also post the github-labeler result to the GitHub comment.
.github/workflows/sync_labels_dryrun.yml
name: Sync labelson: [pull_request]jobs:
sync:
name: Dry runruns-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@v1
- name: Sync labels with dryrun optionuses: b4b4r07/github-labeler@masterwith:
dryrun: 'true'env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}id: labeler
- name: Post github-labeler command result to GitHub commentuses: b4b4r07/action-github-comment@masterif: steps.labeler.outputs.resultwith:
body: | ## github-labeler result ``` ${{ steps.labeler.outputs.result }} ```env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}LOG: traceThis is the workflow to import your existing labels on GitHub to the definition YAML. Even if you define the labels on YAML file, someone may change the label information or create new one on GitHub (Web UI). If so, these labels updating should be synced with the definition file. In order to solve those problems, this workflow imports label-related changes triggered by events of labels activities.
.github/workflows/import_labels.yml
name: Import labelson:
label:
types:
- created
- edited
- deletedjobs:
sync:
runs-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@1.0.0
- name: Import between existing labelsuses: b4b4r07/github-labeler@masterwith:
import: 'true'env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Requestuses: peter-evans/create-pull-request@v1with:
token: ${{ secrets.GITHUB_TOKEN }}commit-message: "Import existing labels"title: "Import existing labels"body: | ## WHAT This pull request was created by [create-pull-request](https://github.com/peter-evans/create-pull-request). ## WHY Current labels.yaml and existing labels don't match.branch: import-labelsbranch-suffix: timestampDownload the binary from GitHub Releases and drop it in your $PATH.




