Created
August 2, 2022 10:38
-
-
Save nottrobin/e956ad3e0287275e74b8ec579f0354d5 to your computer and use it in GitHub Desktop.
Add "web-and-design" topic to all our team's repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from github import Github | |
token = "REPLACE_ME" | |
g = Github(token) | |
org = g.get_organization("canonical") | |
teams = org.get_teams() | |
team = [team for team in teams if team.slug == "web-and-design"][0] | |
repos = team.get_repos() | |
for repo in repos: | |
topics = repo.get_topics() | |
if "web-and-design" not in topics: | |
topics.append("web-and-design") | |
response = requests.put( | |
f"https://api.github.com/repos/canonical/{repo.name}/topics", | |
headers={ | |
"Accept": "application/vnd.github+json", | |
"Authorization": f"token {token}", | |
}, | |
data=json.dumps({"names": topics}), | |
) | |
print(f"{response.status_code}: {repo.name}: {response.text}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment