-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
34 lines (26 loc) · 880 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from github import Github, GithubException
from constants import TOKEN, LABELS
def create_or_update_labels(owner, repo):
print('Creating or updating labels!!')
g = Github(TOKEN)
repo = g.get_repo(f"{owner}/{repo}")
for label in LABELS:
try:
repo.create_label(**label)
except GithubException as e:
# print(e)
repo_label = repo.get_label(label.get('name'))
repo_label.edit(
name=repo_label.name,
color=label.get('color'),
description=label.get('description')
)
except Exception as e:
# print(e)
raise e
def delete_existing_labels(owner, repo):
print('Deleting old labels!!!')
g = Github(TOKEN)
repo = g.get_repo(f"{owner}/{repo}")
for label in repo.get_labels():
label.delete()