This repository was archived by the owner on Jun 28, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ script:
3535
3636after_success :
3737 - coveralls
38+ - ./build_doc.py
3839
3940deploy :
4041 - provider : releases
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22
33from subprocess import check_output
4+ import shlex
5+ import os
46import logging
57
68
1517HTML_DIR = 'html'
1618
1719
18- def run_cmd (cmd ):
19- logging .info ('command: {}' .format (cmd ))
20- result = check_output (cmd .split ()).strip ()
21- if result :
20+ def run_cmd (cmd , quiet = False ):
21+ if not quiet :
22+ logging .info ('command: {}' .format (cmd ))
23+
24+ # use shlex to keep quoted substrings
25+ result = check_output (shlex .split (cmd )).strip ()
26+
27+ if result and not quiet :
2228 logging .debug (result .decode ())
29+
2330 return result
2431
2532
@@ -58,12 +65,37 @@ def update_html():
5865 dst = destination ))
5966
6067
68+ def get_commit_message ():
69+ return run_cmd ('git log -1 --pretty="%s"' )
70+
71+
72+ def get_repo_url ():
73+ return run_cmd ('git remote get-url origin' )
74+
75+
76+ def commit_to_github ():
77+ run_cmd ('pip install -U ghp-import' )
78+ msg = get_commit_message ().decode ()
79+ cmd = 'ghp-import -n -r origin -b gh-pages -m "{}" {}' .format (msg ,
80+ HTML_DIR )
81+ run_cmd (cmd )
82+
83+ url = get_repo_url ().decode ().lstrip ('https://' )
84+ gh_token = os .environ ['GH_TOKEN' ]
85+ # Please set your GH_TOKEN as Travis CI
86+ cmd = 'git push -fq \
87+ https://{}@{}.git gh-pages:gh-pages' .format (gh_token ,
88+ url )
89+ run_cmd (cmd , quiet = True )
90+
91+
6192def main ():
6293 clean_old_build ()
6394 build_docstring_rst ()
6495 build_html ()
6596 duplicate_old_html ()
6697 update_html ()
98+ commit_to_github ()
6799
68100
69101if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments