Files
becomingone/close_all_issues.py
T

41 lines
1.3 KiB
Python

import os
import requests
import sys
def close_issues():
token = os.environ.get("GITHUB_TOKEN")
if not token:
print("Error: GITHUB_TOKEN environment variable not set.", file=sys.stderr)
sys.exit(1)
headers = {
"Authorization": f"token {token}",
"Accept": "application/vnd.github.v3+json"
}
# We want to close issues 34 to 61 inclusive
for issue_number in range(34, 62):
url = f"https://api.github.com/repos/mrhavens/becomingone/issues/{issue_number}"
# First add a comment
comment_url = f"{url}/comments"
comment_data = {
"body": "Sovereign Audit fixes merged into master (Iter 6). The fractures are mathematically mended for POSTERITY."
}
requests.post(comment_url, headers=headers, json=comment_data)
# Then close the issue
data = {
"state": "closed"
}
response = requests.patch(url, headers=headers, json=data)
if response.status_code == 200:
print(f"Successfully closed issue #{issue_number}")
else:
print(f"Failed to close issue #{issue_number}. Status: {response.status_code}")
print(response.text)
if __name__ == "__main__":
close_issues()