Last active
October 4, 2023 09:53
-
-
Save ekohl/cb6a252b34c7093fb0ef1b439a95e54f 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
#!/usr/bin/env python3 | |
import os | |
from github import Github | |
TO_CLEAN = ( | |
'https://prprocessor.theforeman.org', | |
'https://notify.travis-ci.org', | |
'https://ossistant-inecas.rhcloud.com', | |
) | |
TO_KEEP = ( | |
'https://ci.theforeman.org', | |
) | |
GITHUB_ORG = 'theforeman' | |
GITHUB_TOKEN = os.environ['GITHUB_TOKEN'] | |
g = Github(GITHUB_TOKEN) | |
org = g.get_organization(GITHUB_ORG) | |
for repo in org.get_repos(): | |
if not repo.archived: | |
for hook in repo.get_hooks(): | |
url = hook.config['url'] | |
if url.startswith(TO_CLEAN): | |
print(f'{repo.name}: Removing {url}') | |
hook.delete() | |
elif url.startswith(TO_KEEP): | |
pass | |
else: | |
print(f'{repo.name}: Keeping {url}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment