Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Commit

Permalink
Add auto deploy docs to gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
wdv4758h committed Jun 18, 2016
1 parent adfe901 commit 745fdfd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ script:

after_success:
- coveralls
- ./build_doc.py

deploy:
- provider: releases
Expand Down
40 changes: 36 additions & 4 deletions build_doc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3

from subprocess import check_output
import shlex
import os
import logging


Expand All @@ -15,11 +17,16 @@
HTML_DIR = 'html'


def run_cmd(cmd):
logging.info('command: {}'.format(cmd))
result = check_output(cmd.split()).strip()
if result:
def run_cmd(cmd, quiet=False):
if not quiet:
logging.info('command: {}'.format(cmd))

# use shlex to keep quoted substrings
result = check_output(shlex.split(cmd)).strip()

if result and not quiet:
logging.debug(result.decode())

return result


Expand Down Expand Up @@ -58,12 +65,37 @@ def update_html():
dst=destination))


def get_commit_message():
return run_cmd('git log -1 --pretty="%s"')


def get_repo_url():
return run_cmd('git remote get-url origin')


def commit_to_github():
run_cmd('pip install -U ghp-import')
msg = get_commit_message().decode()
cmd = 'ghp-import -n -r origin -b gh-pages -m "{}" {}'.format(msg,
HTML_DIR)
run_cmd(cmd)

url = get_repo_url().decode().lstrip('https://')
gh_token = os.environ['GH_TOKEN']
# Please set your GH_TOKEN as Travis CI
cmd = 'git push -fq \
https://{}@{}.git gh-pages:gh-pages'.format(gh_token,
url)
run_cmd(cmd, quiet=True)


def main():
clean_old_build()
build_docstring_rst()
build_html()
duplicate_old_html()
update_html()
commit_to_github()


if __name__ == '__main__':
Expand Down

0 comments on commit 745fdfd

Please sign in to comment.