35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
import os
|
|
import requests
|
|
import json
|
|
import sys
|
|
|
|
def get_issues(output_file):
|
|
token = os.environ.get("GITHUB_TOKEN")
|
|
if not token:
|
|
print("Error: GITHUB_TOKEN environment variable not set.", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
url = "https://api.github.com/repos/mrhavens/becomingone/issues?state=open&per_page=100"
|
|
headers = {
|
|
"Authorization": f"token {token}",
|
|
"Accept": "application/vnd.github.v3+json"
|
|
}
|
|
|
|
response = requests.get(url, headers=headers)
|
|
if response.status_code == 200:
|
|
issues = response.json()
|
|
with open(output_file, 'w') as f:
|
|
json.dump(issues, f, indent=2)
|
|
print(f"Successfully fetched {len(issues)} issues to {output_file}")
|
|
else:
|
|
print(f"Failed to fetch issues. Status: {response.status_code}", file=sys.stderr)
|
|
print(response.text, file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 2:
|
|
print("Usage: python get_issues.py <output_file>", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
get_issues(sys.argv[1])
|