-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.py
executable file
·55 lines (41 loc) · 1.28 KB
/
deploy.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
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
from subprocess import check_output
import platform
import os
import tempfile
import shutil
import time
from colorama import Fore
def run(cmd):
# given a command string, it runs it
cmds = cmd.split()
return check_output(cmds)
REMOTE = "git@github.com:walchko/walchko.github.io.git"
REPO = "github.com/walchko/walchko.github.io"
BRANCH = "master"
FOLDER = "html"
tmp = tempfile.mkdtemp()
# recursively copy everything to the tmp directory
# make a new git repo and push everything to the branch
# this will make github display the webpages
shutil.copytree('html', tmp + '/html')
os.chdir(tmp + '/html')
print('====================')
print(' Redoing git')
print('====================')
# create readme with data
readme = "# Blog\n\nThis site is automatically generated\n\nUpdated on {}".format(time.strftime("%Y-%m-%d %H:%M"))
with open('readme.md', 'w') as fd:
fd.write(readme)
run('git init')
run('git add *')
run('git commit -m "updated-on-{}:{}-:space_invader:"'.format(REPO, BRANCH))
print('====================')
print(' git push')
print('====================')
run('git push --force {} main:{}'.format(REMOTE, BRANCH))
#run('git push --force {}'.format(REMOTE))
# from glob import glob
# print(os.getcwd())
# for g in glob('*'):
# print(g)