DEV Community

Kyle Harrison
Kyle Harrison

Posted on

Sharing Github Labels across Repositories

Labels (https://github.com/hackebrot/labels) is a CLI app for managing GitHub labels. It allows labels to be fetched and stored in a toml file (which can then be updated to include the required labels on another repository). Once fetched, the labels can then be synced to another repository.

Getting setup

pip install labels

export LABELS_USERNAME="apoclyps"
export LABELS_TOKEN=$GITHUB_TOKEN
Enter fullscreen mode Exit fullscreen mode

Now you are ready to fetch labels from your chosen repository

Copying labels

labels fetch -o apoclyps -r reviews
Enter fullscreen mode Exit fullscreen mode

This will create an output file in your current working directory called labels.toml

[bug]
color = "d73a4a"
name = "bug"
description = "Something isn't working"

[config]
color = "93447B"
name = "config"
description = ""

["contains: migrations"]
color = "EDFA48"
name = "contains: migrations"
description = ""

[dependencies]
color = "030750"
name = "dependencies"
description = ""
Enter fullscreen mode Exit fullscreen mode

Syncing labels

To do a dry run using the -n flag to see what changes would be applied

labels sync -n -o apoclyps -r deps 
Enter fullscreen mode Exit fullscreen mode
This would delete the following labels:
  - yaml
This would update the following labels:
  - contains: migrations
  - dependencies
This would create the following labels:
  - config
This would NOT modify the following labels:
  - bug
Enter fullscreen mode Exit fullscreen mode

If you are happy with the changes, rerun the same command without -n to apply the labels to the repository:

labels sync -n -o apoclyps -r deps 
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
kbedevel profile image
Benjamin Calisto

Interesting tool.

Just adding to this post, GitHub CLI currently supports label managing.