@@ -13,12 +13,12 @@ import json
1313import requests
1414
1515# Authentication for the user who is filing the issue. Username/API_KEY
16- USERNAME = ''
17- API_KEY = ''
16+ USERNAME = ""
17+ API_KEY = ""
1818
1919# The repository to add this issue to
20- REPO_OWNER = ' my-github-org'
21- REPO_NAME = ' github-test-admin'
20+ REPO_OWNER = " my-github-org"
21+ REPO_NAME = " github-test-admin"
2222
2323
2424def create_github_issue (title , body = None , labels = None ):
@@ -30,32 +30,33 @@ def create_github_issue(title, body=None, labels=None):
3030 :return:
3131 """
3232 # Our url to create issues via POST
33- url = f' https://api.github.com/repos/{ REPO_OWNER } /{ REPO_NAME } /issues'
33+ url = f" https://api.github.com/repos/{ REPO_OWNER } /{ REPO_NAME } /issues"
3434 # Create an authenticated session to create the issue
3535 session = requests .Session ()
3636 session .auth = (USERNAME , API_KEY )
3737 # Create the issue
38- issue = {'title' : title ,
39- 'body' : body ,
40- 'labels' : labels }
38+ issue = {"title" : title , "body" : body , "labels" : labels }
4139 # Add the issue to our repository
4240 r = session .post (url , json .dumps (issue ))
4341 if r .status_code == 201 :
4442 print ('Successfully created Issue "%s"' % title )
4543 else :
4644 print ('Failed to create Issue "%s"' % title )
47- print (' Response:' , r .content )
45+ print (" Response:" , r .content )
4846
4947
50- if __name__ == ' __main__' :
48+ if __name__ == " __main__" :
5149 with open (sys .argv [1 ]) as jsp :
5250 payload = json .loads (jsp .read ())
53- action = payload ['action' ]
54- repo = payload ['repository' ]['full_name' ]
55- if action == 'deleted' :
56- create_github_issue ('%s was deleted' % repo , 'Seems we\' ve got ourselves a bit of an issue here.\n \n @<user>' ,
57- ['deleted' ])
58-
59- outfile = f'/tmp/webhook-{ repo } .log'
60- with open (outfile , 'w' ) as f :
51+ action = payload ["action" ]
52+ repo = payload ["repository" ]["full_name" ]
53+ if action == "deleted" :
54+ create_github_issue (
55+ "%s was deleted" % repo ,
56+ "Seems we've got ourselves a bit of an issue here.\n \n @<user>" ,
57+ ["deleted" ],
58+ )
59+
60+ outfile = f"/tmp/webhook-{ repo } .log"
61+ with open (outfile , "w" ) as f :
6162 f .write (json .dumps (payload ))
0 commit comments