38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import os
|
|
import requests
|
|
import sys
|
|
|
|
def submit_issue(title, body_file):
|
|
token = os.environ.get("GITHUB_TOKEN")
|
|
if not token:
|
|
print("Error: GITHUB_TOKEN environment variable not set.", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
with open(body_file, "r") as f:
|
|
body = f.read()
|
|
|
|
url = "https://api.github.com/repos/mrhavens/becomingone/issues"
|
|
headers = {
|
|
"Authorization": f"token {token}",
|
|
"Accept": "application/vnd.github.v3+json"
|
|
}
|
|
data = {
|
|
"title": title,
|
|
"body": body
|
|
}
|
|
|
|
response = requests.post(url, headers=headers, json=data)
|
|
if response.status_code == 201:
|
|
print(f"Successfully created issue: {response.json()['html_url']}")
|
|
else:
|
|
print(f"Failed to create issue. Status: {response.status_code}", file=sys.stderr)
|
|
print(response.text, file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 3:
|
|
print("Usage: python submit_issue.py <title> <body_file>", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
submit_issue(sys.argv[1], sys.argv[2])
|