11#!/usr/bin/python3
22import requests
33import json
4+ import sys
45import re
56
67def run (token , owner , repository , title , body , labels , assignees ):
@@ -26,19 +27,41 @@ def run(token, owner, repository, title, body, labels, assignees):
2627 "Accept" : "application/vnd.github.v3+json" ,
2728 "Authorization" : authorization ,
2829 }
29-
30- r = requests .post (
30+
31+ r1 = requests .get (
3132 url = url ,
32- data = json_data ,
3333 headers = headers
3434 )
35+
36+ if r1 .status_code == 200 :
37+ issues = r1 .json ()
38+
39+ for issue in issues :
40+ if issue ["title" ] == title :
41+ print (f"👀 Issue with the same title already exists on \033 [36mhttps://github.com/{ owner } /{ repository } \033 [0m!" )
42+ print ("Please, update the ISSUE title." )
43+ sys .exit ()
44+ if issue ["body" ] == body :
45+ print (f"👀 Issue with the same description already exists on \033 [36mhttps://github.com/{ owner } /{ repository } \033 [0m!" )
46+ print ("Please, update the ISSUE description." )
47+ sys .exit ()
48+
49+ r2 = requests .post (
50+ url = url ,
51+ data = json_data ,
52+ headers = headers
53+ )
3554
36- if r .status_code == 201 :
37- print (f"✅ Issue successfully created on \033 [36mhttps://github.com/{ owner } /{ repository } \033 [0m!" )
55+ if r2 .status_code == 201 :
56+ print (f"✅ Issue successfully created on \033 [36mhttps://github.com/{ owner } /{ repository } \033 [0m!" )
3857
58+ else :
59+ print (f"❌ Couldn't create new issue on \033 [36mhttps://github.com/{ owner } /{ repository } " )
60+ print (r2 .status_code , r2 .reason , r2 .content )
61+
3962 else :
40- print (f"❌ Couldn't create new issue on \033 [36mhttps://github.com/{ owner } /{ repository } " )
41- print (r .status_code , r .reason , r .content )
63+ print (f"❌ Couldn't check issues on \033 [36mhttps://github.com/{ owner } /{ repository } " )
64+ print (r1 .status_code , r1 .reason , r1 .content )
4265
4366def format (value ):
44- return re .sub (' ' , '' , value ).strip ().split ("," )
67+ return re .sub (' ' , '' , value ).strip ().split ("," )
0 commit comments