-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpublish.py
executable file
·46 lines (35 loc) · 939 Bytes
/
publish.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
#!/usr/bin/env python
from subprocess import check_call as run
from os import getcwd, chdir
from os.path import join
from shutil import rmtree, copytree
from tempfile import mkdtemp
from contextlib import contextmanager
REPO = '[email protected]:alexanderkuk/analyze-vk-groups.git'
@contextmanager
def tmpdir():
try:
path = mkdtemp()
yield path
finally:
rmtree(path)
@contextmanager
def cwd(path):
old_path = getcwd()
try:
chdir(path)
yield
finally:
chdir(old_path)
def publish():
with tmpdir() as root:
path = join(root, 'html')
copytree('viz', path)
with cwd(path):
run(['git', 'init'])
run(['touch', '.nojekyll'])
run(['git', 'add', '.'])
run(['git', 'commit', '-m', 'up'])
run(['git', 'push', '--force', REPO, 'master:gh-pages'])
if __name__ == '__main__':
publish()