-
Notifications
You must be signed in to change notification settings - Fork 2
/
push_profile.py
47 lines (35 loc) · 1.59 KB
/
push_profile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
import os
from datetime import datetime
def push_profile(repo_dir, profile_name):
web_root = "https://rsdunlapiv.github.io/esmf-profile-example"
# temp directory
#tmp_dir = "./repotmp"
#if not os.path.isdir(tmp_dir):
# os.makedirs(tmp_dir)
# print("Created tmp directory: {}".format(tmp_dir))
#git_cmd = "cd {}; git checkout {}; git add {}/{};git commit -a -m\'update\';git push origin {}".format(
# self.artifacts_root,self.machine_name,dirbranch,self.machine_name,build_basename,self.build_hash,self.machine_name,self.machine_name)
if not os.path.isdir(repo_dir):
print("Not a valid repository directory: {}".format(repo_dir))
return
profile_dir = "out/{}".format(profile_name)
if not os.path.isdir(profile_dir):
print("Not a valid profile directory: {}".format(profile_dir))
return
cmd = "cd {}; git pull".format(repo_dir)
print("CMD: {}".format(cmd))
os.system(cmd)
cmd = "cp -R {} {}".format(profile_dir, repo_dir)
print("CMD: {}".format(cmd))
os.system(cmd)
cmd = "cd {}; git add {}/*; git commit -a -m \'update\'; git push origin".format(repo_dir, profile_name)
print("CMD: {}".format(cmd))
os.system(cmd)
print("Profile URL: {}/{}/".format(web_root, profile_name))
print(" NOTE: It may take up to several minutes for the profile to be live.")
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python3 push_profile.py <repo_dir> <profile_name>\n")
else:
push_profile(sys.argv[1], sys.argv[2])