Created
September 27, 2016 19:13
-
-
Save nqthqn/dd6e10df8e17813ca8c02c5f178d5575 to your computer and use it in GitHub Desktop.
uses the "requests" library to talk to github API and create github issues from a spreadsheet
This file contains hidden or 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 json | |
import requests | |
import csv | |
# Authentication for user filing issue (must have read/write access to | |
# repository to add issue to) | |
USERNAME = 'username' | |
PASSWORD = 'password' | |
# The repository to add this issue to | |
REPO_OWNER = 'owner' | |
REPO_NAME = 'repo' | |
def make_github_issue(title, body=None, assignee=None, milestone=None, labels=None): | |
'''Create an issue on github.com using the given parameters.''' | |
# Our url to create issues via POST | |
url = 'https://api.github.com/repos/%s/%s/issues' % (REPO_OWNER, REPO_NAME) | |
# Create an authenticated session to create the issue | |
session = requests.Session() | |
session.auth = (USERNAME, PASSWORD) | |
# Create our issue | |
issue = {'title': title, | |
'body': body, | |
'assignee': assignee, | |
'milestone': milestone, | |
'labels': labels} | |
# Add the issue to our repository | |
r = session.post(url, json.dumps(issue)) | |
if r.status_code == 201: | |
print('Successfully created Issue "%s"' % title) | |
else: | |
print('Could not create Issue "%s"' % title) | |
print('Response:', r.content) | |
with open('issues.csv', 'r') as csvfile: | |
reader = csv.DictReader(csvfile) | |
for row in reader: | |
make_github_issue(row['title'], row['body'], milestone=3, labels=['iosapp']) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment