Skip to content

Commit

Permalink
QAR-49181: deploy doc to ghpages from travis
Browse files Browse the repository at this point in the history
  • Loading branch information
hellmanj committed Nov 20, 2014
1 parent b5e32c7 commit 1437329
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
env:
global:
secure: aStjr7/mZJDdPqJ210HPRZygxXA36SzXyBraK9x6eqaDR+yqZpGJBIYMlRzqV1Fwlh1BUFbOYNczmLEQs+Sf3uPxyEWhFc5L0qKlvUE98fsf6IJuFJdwfwBG1/vrJTNm0JviBI/6lPlB2/EYtJJBWmYQGsrXXoP5Cc38T+z/a0s=
language: python
python:
- "2.7"
Expand All @@ -13,3 +16,5 @@ deploy:
on:
tags: true
all_branches: true
after_success:
- python deploy-ghpages.py
40 changes: 40 additions & 0 deletions deploy-ghpages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Travis CI Script for generating libdoc for robotpageobjects.Page and publishing it
"""

from os import getenv, chdir
from re import sub
from subprocess import check_output, check_call
from tempfile import mkdtemp
from shutil import rmtree

if getenv('TRAVIS_REPO_SLUG') != 'ncbi/robotframework-pageobjects':
print "Repo is a fork, not building docs"
exit()

if getenv('TRAVIS_BRANCH') != 'master':
print "Branch is not master, not building docs"
exit()

if getenv('TRAVIS_PULL_REQUEST') != 'false':
print "Pull request detected, not building docs"
exit()

repo = check_output("git config remote.origin.url", shell=True)
repo = sub(r'^git:', 'https:', repo).strip()
deploy_url = sub(r'https://', 'https://%s@' % getenv('GIT_TOKEN'), repo)
deploy_branch = 'gh-pages'
rev = check_output("git rev-parse HEAD", shell=True).strip()

dir = mkdtemp()
check_call("git clone --branch %s %s %s" % (deploy_branch, repo, dir), shell=True)
chdir(dir)
check_call("python -m robot.libdoc robotpageobjects.page.Page index.html", shell=True)
print "Docs built successfully"
check_call("git config user.name '%s'" % getenv('GIT_NAME'), shell=True)
check_call("git config user.email '%s'" % getenv('GIT_EMAIL'), shell=True)
check_call("git commit -m 'Built from %s' index.html" % rev, shell=True)
check_call("git push -q %s %s" % (deploy_url, deploy_branch), shell=True)
chdir(getenv('TRAVIS_BUILD_DIR'))
rmtree(dir)
print "Docs pushed successfully"

0 comments on commit 1437329

Please sign in to comment.