-
Notifications
You must be signed in to change notification settings - Fork 3
/
upload-draft.py
34 lines (28 loc) · 1.03 KB
/
upload-draft.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
import os
import sys
import subprocess
import shutil
if os.environ['TRAVIS_PULL_REQUEST'] != "false":
sys.exit(0)
if len(sys.argv) != 2:
sys.exit(1)
built = sys.argv[1]
os.mkdir("out")
os.chdir("out")
subprocess.check_call(["git","init","."])
subprocess.check_call(["git","config","--global","user.email","[email protected]"])
subprocess.check_call(["git","config","--global","user.name","EKR CI Bot"])
subprocess.check_call(["git","config","core.askpass","true"])
shutil.copy("../%s"%built, "index.html")
subprocess.check_call(["git","add", "index.html"])
subprocess.check_call(["git","commit","-m", "Commit"])
try:
subprocess.check_output(["git","push","--force","https://%s@%s"%(os.environ['GH_TOKEN'],
os.environ['GH_REF'])
,"master:gh-pages","-q"],
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE)
except:
sys.stderr.write("Upload failed\n")
sys.exit(1)
sys.exit(0)