Created
January 5, 2024 23:28
-
-
Save sudodo/c0d1bf5fc7c594f00e4d258cf44eef9f to your computer and use it in GitHub Desktop.
create Github issues from JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import os | |
# Set your personal access token | |
token = os.environ.get('GITHUB_TOKEN') | |
your_username = 'sudodo' | |
your_repo = 'your_repo' | |
# Replace with the appropriate URL for your repository's issues | |
url = f"https://api.github.com/repos/{your_username}/{your_repo}/issues" | |
# Your JSON data | |
issues = [ | |
{ | |
"title": "Fix this bug", | |
"body": "This is description of this bug" | |
}, | |
{ | |
"title": "Fix that bug", | |
"body": "This is description of that bug" | |
}, | |
] | |
headers = {'Authorization': f'token {token}'} | |
for issue in issues: | |
response = requests.post(url, headers=headers, data=json.dumps(issue)) | |
if response.status_code == 201: | |
print(f"Issue created: {issue['title']}") | |
else: | |
print(f"Failed to create issue: {response.content}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment