Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/babarot/github-labeler
Declarative way to configure GitHub labels
https://github.com/babarot/github-labeler
github-actions github-labels go golang yaml
Last synced: 3 months ago
JSON representation
Declarative way to configure GitHub labels
- Host: GitHub
- URL: https://github.com/babarot/github-labeler
- Owner: babarot
- Created: 2018-11-19T10:39:26.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-26T07:12:47.000Z (almost 2 years ago)
- Last Synced: 2024-10-24T23:26:44.682Z (4 months ago)
- Topics: github-actions, github-labels, go, golang, yaml
- Language: Go
- Homepage:
- Size: 1.88 MB
- Stars: 75
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GitHub labels as a Code!
========================![](docs/demo.png)
CLI that sets GitHub labels exactly as written in YAML file
## Concepts
- 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)## YAML example
```yaml
labels:
- name: kind/proactive
description: Categorizes issue or PR as related to proactive tasks.
color: 9CCC65
- name: kind/reactive
description: Categorizes issue or PR as related to reactive tasks.
color: FFA000repos:
- name: org/repo
labels:
- kind/proactive
- kind/reactive
```## Run as GitHub Actions
### YAML for defined labels
You 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
```yaml
labels:
- name: help wanted
description: Extra attention is needed
color: "008672"
- name: bug
description: Something isn't working
color: fc2929
- name: enhancement
description: New feature or request
color: 84b6eb
- name: question
description: Further information is requested
color: cc317c
repos:
- name: user/repo
labels:
- help wanted
- bug
- enhancement
- question
```### YAML for workflows to sync labels between existing one and defined one
This 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
```yaml
name: Sync labelson:
push:
branches:
- master
paths:
- .github/labels.ymljobs:
sync:
name: Run
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Sync labels
uses: b4b4r07/github-labeler@master
env:
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](https://github.com/b4b4r07/action-github-comment) step, you can also post the github-labeler result to the GitHub comment.
.github/workflows/sync_labels_dryrun.yml
```yaml
name: Sync labelson: [pull_request]
jobs:
sync:
name: Dry run
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Sync labels with dryrun option
uses: b4b4r07/github-labeler@master
with:
dryrun: 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: labeler
- name: Post github-labeler command result to GitHub comment
uses: b4b4r07/action-github-comment@master
if: steps.labeler.outputs.result
with:
body: |
## github-labeler result
```
${{ steps.labeler.outputs.result }}
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOG: trace
```
### YAML for workflows to import labels from existing one to defined one
This 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
```yaml
name: Import labelson:
label:
types:
- created
- edited
- deletedjobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Import between existing labels
uses: b4b4r07/github-labeler@master
with:
import: 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v1
with:
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-labels
branch-suffix: timestamp
```
## Installation
Download the binary from [GitHub Releases][release] and drop it in your `$PATH`.
- [Darwin / Mac][release]
- [Linux][release]## License
[MIT][license]
[release]: https://github.com/b4b4r07/github-labeler/releases/latest
[license]: https://b4b4r07.mit-license.org