Skip to content

Instantly share code, notes, and snippets.

@sudodo
Created January 5, 2024 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudodo/c0d1bf5fc7c594f00e4d258cf44eef9f to your computer and use it in GitHub Desktop.
Save sudodo/c0d1bf5fc7c594f00e4d258cf44eef9f to your computer and use it in GitHub Desktop.
create Github issues from JSON
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