Skip to content

Instantly share code, notes, and snippets.

@ekohl
Last active October 4, 2023 09:53
Show Gist options
  • Save ekohl/cb6a252b34c7093fb0ef1b439a95e54f to your computer and use it in GitHub Desktop.
Save ekohl/cb6a252b34c7093fb0ef1b439a95e54f to your computer and use it in GitHub Desktop.
#!/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