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
💡 One last tip before you go

Tired of spending so much on your side projects? 🤔

We have created a membership program that helps cap your costs so you can build and experiment for less. And we currently have early-bird pricing which makes it an even better value! 🐥

Check out DEV++

Top comments (1)

Collapse
 
kbedevel profile image
Benjamin Calisto

Interesting tool.

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

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay