Created
October 1, 2021 21:08
-
-
Save mrakitin/48e85bcfab58770739b861803fc6a891 to your computer and use it in GitHub Desktop.
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 os | |
from github import Github | |
token = os.getenv("GITHUB_ACCESS_TOKEN") | |
gh_org = os.getenv("GITHUB_ORG_UPDATE_TOPICS", "bluesky") | |
g = Github(token) | |
all_repos = {} | |
for repo in g.get_organization(gh_org).get_repos(): | |
print(repo.name) | |
all_repos[repo.name] = repo | |
add_topics = ["hacktoberfest", "hacktoberfest2021"] | |
for name, repo in all_repos.items(): | |
if ( | |
name.startswith(("bluesky", "suitcase")) | |
or name in ["ophyd", "databroker", "databroker-pack"] | |
) and not repo.archived: | |
topics = repo.get_topics() | |
print(f"{name}: {topics}") | |
if not set(topics).intersection(add_topics): | |
print(f"\t{name} does not have {add_topics}. To be updated...") | |
topics += add_topics | |
print(f"\tUpdated topics: {topics}\n") | |
repo.replace_topics(topics) | |
else: | |
print(f"\t{name} has {add_topics}. To be skipped.\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements:
Sample output: