forked from DongZhouGu/arxiv-daily
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github_issue.py
48 lines (39 loc) · 1.43 KB
/
github_issue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# encoding: utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import json
import requests
from config import REPO_OWNER, REPO_NAME
def make_github_issue(title, body=None, assignee=None, TOKEN=None, closed=False, labels=[]):
# Create an issue on github.com using the given parameters
# Url to create issues via POST
url = 'https://api.github.com/repos/%s/%s/import/issues' % (REPO_OWNER, REPO_NAME)
# Headers
headers = {
"Authorization": "token %s" % TOKEN,
"Accept": "application/vnd.github.golden-comet-preview+json"
}
# Create our issue
data = {'issue': {'title': title,
'body': body,
'assignee': assignee,
'closed': closed,
'labels': labels}}
payload = json.dumps(data)
# Add the issue to our repository
response = requests.request("POST", url, data=payload, headers=headers)
if response.status_code == 202:
print('Successfully created Issue "%s"' % title)
else:
print('Could not create Issue "%s"' % title)
print('Response:', response.content)
if __name__ == '__main__':
title = 'Pretty title'
body = 'Beautiful body'
assignee = ''
TOKEN = ''
closed = False
labels = ["bug"]
make_github_issue(title, body, assignee, TOKEN, closed, labels)