Skip to content

Instantly share code, notes, and snippets.

@0187773933
Created January 5, 2023 16:03
Show Gist options
  • Save 0187773933/696ec71ec85d2308c920dae177dcb7fe to your computer and use it in GitHub Desktop.
Save 0187773933/696ec71ec85d2308c920dae177dcb7fe to your computer and use it in GitHub Desktop.
Turns Off Issues on All Repositories in a Github Account
#!/usr/bin/env python3
import requests
from pprint import pprint
TOKEN = "API_TOKEN"
USERNAME = "GITHUB_USERNAME"
API_BASE_URL = "https://api.github.com"
# https://docs.github.com/en/rest/repos/repos#update-a-repository
if __name__ == "__main__":
repo_response = requests.get(f"{API_BASE_URL}/users/{USERNAME}/repos", headers={"Authorization": f"token {TOKEN}"})
repos = repo_response.json()
for index , repo in enumerate( repos ):
setting_response = requests.get(f"{API_BASE_URL}/repos/{USERNAME}/{repo['name']}", headers={"Authorization": f"token {TOKEN}"})
settings = setting_response.json()
if settings[ "has_issues" ] != False:
patch_response = requests.patch(f"{API_BASE_URL}/repos/{USERNAME}/{repo['name']}", json={ "owner": USERNAME , "repo": repo['name'] , "has_issues": False }, headers={"Authorization": f"token {TOKEN}"})
print( repo['name'] , settings[ "has_issues" ] , patch_response.status_code )
else:
print( repo['name'] , settings[ "has_issues" ] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment