rdmorganiser / .github

Community health files for the @rdmorganiser organization
Apache License 2.0
0 stars 1 forks source link

Set up labels from the RDMO repository #11

Closed afuetterer closed 2 months ago

afuetterer commented 2 months ago

Ref: https://github.com/rdmorganiser/rdmo/labels

"Migrations" label is not needed here.

afuetterer commented 2 months ago

Getting the labels with PyGithub.

import json
from operator import itemgetter
from pprint import pprint

from github import Github

g = Github()
repo = g.get_repo("rdmorganiser/rdmo")

# get all labels from repository
labels = [
    {"name": _label.name, "description": _label.description, "color": _label.color}
    for _label in repo.get_labels()
]

# remove empty descriptions
for label in labels:
    if not label["description"]:
        label.pop("description")

# sort by name
labels = sorted(labels, key=itemgetter("name"))

with open("labels.json", "w") as f:
    f.write(json.dumps(labels, indent=2))

g.close()