Skip to content

Instantly share code, notes, and snippets.

@cidrblock
Created February 20, 2020 14:07
Show Gist options
  • Save cidrblock/8b2b2c73103e48ce5bddfdf75bb23dfb to your computer and use it in GitHub Desktop.
Save cidrblock/8b2b2c73103e48ce5bddfdf75bb23dfb to your computer and use it in GitHub Desktop.
from datetime import datetime, timezone
import dateutil.parser
from github3 import GitHub
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
github = GitHub(token=GITHUB_TOKEN)
org = github.organization('ansible-collection-migration')
for repo in org.repositories():
last_pushed = repo.pushed_at
age = datetime.now(timezone.utc) - dateutil.parser.isoparse(last_pushed)
if age.days:
print("Deleting %s %s" % (repo.name, age.days))
# repo.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment