@@ -32,6 +32,16 @@ def get_source_from_registry(source, version):
3232 sys .exit (1 )
3333
3434
35+ def add_github_token (github_download_url ,token ):
36+ github_repo_url_pattern = re .compile ('.*github.com/(.*)/(.*)\.git' )
37+ match = github_repo_url_pattern .match (github_download_url )
38+ url = github_download_url
39+ if match :
40+ user , repo = match .groups ()
41+ url = 'https://{}@github.com/{}/{}.git' .format (token , user , repo )
42+ return url
43+
44+
3545def run (* args , ** kwargs ):
3646 proc = subprocess .Popen (args , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , ** kwargs )
3747 stdout , stderr = proc .communicate ()
@@ -112,6 +122,9 @@ def update_modules(path):
112122 print ('Fetched {}/{}' .format (module_path_name , name ))
113123 continue
114124
125+ # add token to tthe source url if exists
126+ if 'GITHUB_TOKEN' in os .environ :
127+ source = add_github_token (source , os .getenv ('GITHUB_TOKEN' ))
115128 # Delete the old directory and clone it from scratch.
116129 print ('Fetching {}/{}' .format (module_path_name , name ))
117130 shutil .rmtree (target , ignore_errors = True )
0 commit comments