@@ -32,6 +32,16 @@ def get_source_from_registry(source, version):
32
32
sys .exit (1 )
33
33
34
34
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
+
35
45
def run (* args , ** kwargs ):
36
46
proc = subprocess .Popen (args , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , ** kwargs )
37
47
stdout , stderr = proc .communicate ()
@@ -112,6 +122,9 @@ def update_modules(path):
112
122
print ('Fetched {}/{}' .format (module_path_name , name ))
113
123
continue
114
124
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' ))
115
128
# Delete the old directory and clone it from scratch.
116
129
print ('Fetching {}/{}' .format (module_path_name , name ))
117
130
shutil .rmtree (target , ignore_errors = True )
0 commit comments