@@ -35,7 +35,7 @@ def is_public_repo(self, repo):
3535 return self .repo_map [repo ]
3636
3737 repo_path = 'repos' if '/' in repo else 'repositories'
38- url = f'https://api.github.com /{ repo_path } /{ repo } '
38+ url = f'{ ctx . options . GITHUB_API_URL } /{ repo_path } /{ repo } '
3939 response = requests .get (url , headers = {'Authorization' : 'Bearer %s' % ctx .options .token })
4040 if response .status_code == 200 :
4141 self .repo_map [repo ] = response .json ()['private' ] == False
@@ -248,11 +248,9 @@ def get_permission(self, path, method, query):
248248 if id == 'issue_number' :
249249 url = ''
250250 if path_segments [1 ] == 'repos' :
251- url = 'https://api.github.com/repos/%s/%s/pulls/%s' % (
252- path_segments [2 ], path_segments [3 ], path_segments [5 ])
251+ url = f'{ ctx .options .GITHUB_API_URL } /repos/{ path_segments [2 ]} /{ path_segments [3 ]} /pulls/{ path_segments [5 ]} '
253252 elif path_segments [1 ] == 'repositories' :
254- url = 'https://api.github.com/repositories/%s/pulls/%s' % (
255- path_segments [2 ], path_segments [4 ])
253+ url = f'{ ctx .options .GITHUB_API_URL } /repositories/{ path_segments [2 ]} /pulls/path_segments[4]'
256254 response = requests .get (
257255 url , headers = {'Authorization' : 'Bearer %s' % ctx .options .token })
258256 self .log_debug (
@@ -264,11 +262,9 @@ def get_permission(self, path, method, query):
264262 elif id == 'comment_id' :
265263 url = ''
266264 if path_segments [1 ] == 'repos' :
267- url = 'https://api.github.com/repos/%s/%s/issues/comments/%s' % (
268- path_segments [2 ], path_segments [3 ], path_segments [6 ])
265+ url = f'{ ctx .options .GITHUB_API_URL } /repos/{ path_segments [2 ]} /{ path_segments [3 ]} /issues/comments/{ path_segments [6 ]} '
269266 elif path_segments [1 ] == 'repositories' :
270- url = 'https://api.github.com/repositories/%s/issues/comments/%s' % (
271- path_segments [2 ], path_segments [5 ])
267+ url = f'{ ctx .options .GITHUB_API_URL } /repositories/{ path_segments [2 ]} /issues/comments/{ path_segments [5 ]} '
272268 response = requests .get (
273269 url , headers = {'Authorization' : 'Bearer %s' % ctx .options .token })
274270 self .log_debug (
@@ -285,11 +281,9 @@ def get_permission(self, path, method, query):
285281 elif id == 'event_id' :
286282 url = ''
287283 if path_segments [1 ] == 'repos' :
288- url = 'https://api.github.com/repos/%s/%s/issues/events/%s' % (
289- path_segments [2 ], path_segments [3 ], path_segments [6 ])
284+ url = f'{ ctx .options .GITHUB_API_URL } /repos/{ path_segments [2 ]} /{ path_segments [3 ]} /issues/events/{ path_segments [6 ]} '
290285 elif path_segments [1 ] == 'repositories' :
291- url = 'https://api.github.com/repositories/%s/issues/events/%s' % (
292- path_segments [2 ], path_segments [5 ])
286+ url = f'{ ctx .options .GITHUB_API_URL } /repositories/{ path_segments [2 ]} /issues/events/{ path_segments [5 ]} '
293287 response = requests .get (
294288 url , headers = {'Authorization' : 'Bearer %s' % ctx .options .token })
295289 self .log_debug (
@@ -451,6 +445,12 @@ def load(self, loader):
451445 default = '' ,
452446 help = 'Comma delimited list of hosts to monitor' ,
453447 )
448+ loader .add_option (
449+ name = 'GITHUB_API_URL' ,
450+ typespec = str ,
451+ default = '' ,
452+ help = 'GITHUB_API_URL environment variable' ,
453+ )
454454
455455 def log_debug (self , msg ):
456456 if ctx .options .debug :
@@ -487,6 +487,10 @@ def configure(self, updates):
487487 print ('error: GITHUB_REPOSITORY is empty' )
488488 sys .exit (1 )
489489
490+ if not bool (ctx .options .GITHUB_API_URL ):
491+ print ('error: GITHUB_API_URL is empty' )
492+ sys .exit (1 )
493+
490494 self .id_token_request_url = None
491495 if bool (ctx .options .ACTIONS_ID_TOKEN_REQUEST_URL ):
492496 self .id_token_request_url = urlsplit (ctx .options .ACTIONS_ID_TOKEN_REQUEST_URL )
0 commit comments