Skip to content

Commit

Permalink
deploy docs to new repo for security
Browse files Browse the repository at this point in the history
  • Loading branch information
KristoforMaynard committed May 11, 2018
1 parent 58a0995 commit e78c589
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .ghp_squash_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3db7b5b3a92fb8b0f6a1dad3e9149c3dba8c586f
0149a5a7b55a174cc4f8bdd34f58fe010c2aa7c8
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: generic

env:
global:
- secure: "NArKc/MxyQCWqQcnh+qx1rPyw3te01bC8kqbMwKUyOsJNuL9faS+6VnplKhfk7Ck5xAMG5Qvta4CZvCO9lCM1q18Ntfs4KFjmoIlFpRycJqYVM8Lw8mnxGpOEdlVIFi+eWDRAfpEBKjdRnvsnnxnDFo0ROEjfmSrbi47/8h62EcWtTpEUmpLfRVZyUuUOZ4zYXV65ZDVhLWBt5zQWlYOl9CnTI4p8ktf0TffZxFKuhL6xrbEZtLhSfEkfecoWYEJ7luOxixJny3MEeW8LS4MKRA4naVwNk+lNL5yKHgMnz05r5pINXVshUsYcbbWs/odUOwwZDiV/8RMHfht1b+HHrxL8KenSbj4t8NvbgHqEB1wJbrTt3dmZTez5gxnk7g2MYSpSZJHauKQQD5fVR4paSsVEgOioZcL6ZPs8pacXEQ1T3vKd9jhLeQbJppeTR1hvny3N/rnMym2GYVL69a/eIMCoTKPZjTi0l5Ki3jhQOTnmQZJm0NASBA7Vp2f0pZBrOj92bHRkhcNu6wEY1Gzv1+3pDBJLHbp3szQzAiT5eMjoYC5wtcDdTq93jdEXhObhNUUOMOcOzEho+PZSuGrZCa7cjN0WAicQuv1wtXHhdwm5ITEnG7yGSUBfmfDoFFu5P0SkzA6n5v9YfICTQ5zvNX4tcc3dNou8y6xPl4vPsY="
- 'deployable="^(master|dev|travis)$"'
- LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
- QT_API=pyside
Expand Down Expand Up @@ -56,6 +55,14 @@ before_install:
false;
fi'

# setup deployment key
- 'mkdir -p ${HOME}/.ssh'
- 'chmod 700 ${HOME}/.ssh'
- 'if [[ -n ${encrypted_94825f2db120_key} && -n ${encrypted_94825f2db120_iv} ]]; then
openssl aes-256-cbc -K $encrypted_94825f2db120_key -iv $encrypted_94825f2db120_iv -in resources/.doc_deployment_key.enc -out ${HOME}/.ssh/id_rsa -d;
fi'
- 'chmod 600 ${HOME}/.ssh/id_rsa'

## Now setup the Anaconda tools
# it saves some download time to use the same python iff 2.7
- 'if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
Expand Down Expand Up @@ -142,7 +149,7 @@ script:
else
make instcheck;
fi'
- 'if [[ $TRAVIS_BRANCH =~ ${deployable}$ && -n "$GH_TOKEN" ]]; then
- 'if [[ $TRAVIS_BRANCH =~ ${deployable}$ && -f "${HOME}/.ssh/id_rsa" ]]; then
make deploy-summary;
fi'

Expand All @@ -153,4 +160,4 @@ deploy:
- make deploy-html
on:
branch: "*"
condition: '($TRAVIS_BRANCH =~ ${deployable}) && -n "$GH_TOKEN" && ("${DEPLOY_DOCS}" == "1")'
condition: '($TRAVIS_BRANCH =~ ${deployable}) && -f "${HOME}/.ssh/id_rsa" && ("${DEPLOY_DOCS}" == "1")'
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Both the master and dev branches should make every attempt to be usable (thanks

Branch | Docs | Test Status
------------- | ------------------------------------------------------------------------- | -----------------------
[master](https://github.com/KristoforMaynard/Viscid) | [html](http://kristoformaynard.github.io/Viscid/docs/master/index.html), [test summary](http://kristoformaynard.github.io/Viscid/summary/master-2.7/index.html) | [![Build Status](https://travis-ci.org/KristoforMaynard/Viscid.svg?branch=master)](https://travis-ci.org/KristoforMaynard/Viscid)
[dev](https://github.com/KristoforMaynard/Viscid/tree/dev) | [html](http://kristoformaynard.github.io/Viscid/docs/dev/index.html), [test summary](http://kristoformaynard.github.io/Viscid/summary/dev-2.7/index.html) | [![Build Status](https://travis-ci.org/KristoforMaynard/Viscid.svg?branch=dev)](https://travis-ci.org/KristoforMaynard/Viscid)
[master](https://github.com/KristoforMaynard/Viscid) | [html](http://kristoformaynard.github.io/Viscid-docs/docs/master/index.html), [test summary](http://kristoformaynard.github.io/Viscid-docs/summary/master-2.7/index.html) | [![Build Status](https://travis-ci.org/KristoforMaynard/Viscid.svg?branch=master)](https://travis-ci.org/KristoforMaynard/Viscid)
[dev](https://github.com/KristoforMaynard/Viscid/tree/dev) | [html](http://kristoformaynard.github.io/Viscid-docs/docs/dev/index.html), [test summary](http://kristoformaynard.github.io/Viscid-docs/summary/dev-2.7/index.html) | [![Build Status](https://travis-ci.org/KristoforMaynard/Viscid.svg?branch=dev)](https://travis-ci.org/KristoforMaynard/Viscid)

## Install ##

Expand Down Expand Up @@ -51,7 +51,7 @@ installed.

The jrrle and fortbin readers depend on compiled Fortran code, and the interpolation and streamline functions depend on compiled Cython (C) code.

For explicit installation instructions, please refer to the [Quickstart Documentation](http://kristoformaynard.github.io/Viscid/docs/master/installation.html).
For explicit installation instructions, please refer to the [Quickstart Documentation](http://kristoformaynard.github.io/Viscid-docs/docs/master/installation.html).

## Development ##

Expand Down
57 changes: 38 additions & 19 deletions deploy_ghpages
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ msg="Automated Deployment"
dest_dir=""
files=""

upstream_slug="KristoforMaynard/Viscid"
TRAVIS_REPO_SLUG="${TRAVIS_REPO_SLUG:-${upstream_slug}}"
repo_slug=""

# usage: abs_path="$(abspath ${relative_path} [${start}])"
# `start` is the path that the relative path is relative to; it defaults to ${PWD}
Expand All @@ -35,6 +34,7 @@ Copy and commit a set of files to the gh-pages branch
-m MSG commit message
Required Arguments:
-r REPO github repository slug, i.e., "user/repo"
-d DEST Destination directory relative to root on the gh-pages
branch
file* One or more files to move to DEST and commit
Expand All @@ -46,13 +46,14 @@ exit $1
##################
# parse arguments
OPTIND=1
while getopts "h?pcm:d:" arg; do
while getopts "h?pcm:r:d:" arg; do
case $arg in
h|\?)
print_usage 0;;
p) pretend=1;;
c) doclean=1;;
m) msg=${OPTARG};;
r) repo_slug=${OPTARG};;
d) dest_dir=${OPTARG};;
*) print_usage 1;;
esac
Expand All @@ -61,7 +62,23 @@ shift $((OPTIND-1))

files=(); for f in "$@"; do files+=("${f}"); done

if [ -z "${dest_dir}" ] || [ ${#files[@]} -eq 0 ]; then print_usage 1; fi
if [ -z "${dest_dir}" ]; then
echo "Error, missing DEST" >&2
echo "" >&2
print_usage 1
fi

if [ ${#files[@]} -eq 0 ]; then
echo "Error, you must supply one or more FILES" >&2
echo "" >&2
print_usage 2
fi

if [ "${repo_slug}" == "" ]; then
echo "Error, missing REPO" >&2
echo "" >&2
print_usage 3
fi

###################
# now we may begin
Expand All @@ -73,29 +90,31 @@ else
fi

if [[ -n ${TRAVIS} && -n ${CONTINUOUS_INTEGRATION} ]]; then
if [ "${TRAVIS_REPO_SLUG}" != "${upstream_slug}" ]; then
echo ">> slug: '${TRAVIS_REPO_SLUG}' != '${upstream_slug}' (upstream),"
echo ">> i.e., this repo is not eligible for doc deployment. "
echo ">> Quietly exiting now..."
exit 0
elif [ -n "$GH_TOKEN" ]; then
repo="https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git"
git config --global user.name "Travis-CI"
git config --global user.email "[email protected]"
git config --global push.default simple
else
echo ">> I'm lost..."
exit 10
fi
# ok, so now on travis-ci, you will need to create an encrypted
# file that contains a private rsa key. In the before-install
# phase, you'll need to decrypt that file into ~/.ssh/id_rsa
# and give the correct permission to ~/.ssh (700) and
# ~/.ssh/id_rsa (600). Then, you can add the public key to the
# target repository's deployment keys on github.
repo="[email protected]:${repo_slug}.git"
git config --global user.name "Travis-CI"
git config --global user.email "[email protected]"
git config --global push.default simple
else
# this scipt is probably being run locally, so let's assume the user
# has set up passwordless access to github with an account that can
# push to the upstream repo
repo="[email protected]:${TRAVIS_REPO_SLUG}.git"
repo="[email protected]:${repo_slug}.git"
fi

echo "using repo::" ${repo}
git clone -b gh-pages ${repo} "${ghp_dir}"

if [ ! -d ${ghp_dir} ]; then
echo "Repo directory doesn't exist, the clone must have failed." >&2
exit 30
fi

cd "${ghp_dir}"

if [[ ${doclean} && -d "${dest_dir}" ]]; then
Expand Down
5 changes: 4 additions & 1 deletion doc/deploy_html_ghpages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ make clean
make html

msg="Automatic doc update ${branch}:${tags}"
${root_dir}/deploy_ghpages -cd "docs/${branch}" -m "${msg}" "${html_dir}"/*
${root_dir}/deploy_ghpages -cd "docs/${branch}" \
-r "KristoforMaynard/Viscid-docs" \
-m "${msg}" \
"${html_dir}"/*

##
## EOF
Expand Down
8 changes: 4 additions & 4 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ Branch Test Status Docs
=================== ================ ========================================================

.. _master: https://github.com/KristoforMaynard/Viscid
.. _html_master: http://kristoformaynard.github.io/Viscid/docs/master/index.html
.. _tests_master: http://kristoformaynard.github.io/Viscid/summary/master-2.7/index.html
.. _html_master: http://kristoformaynard.github.io/Viscid-docs/docs/master/index.html
.. _tests_master: http://kristoformaynard.github.io/Viscid-docs/summary/master-2.7/index.html
.. |travis-master| raw:: html

<a href="https://travis-ci.org/KristoforMaynard/Viscid">
<img src="https://travis-ci.org/KristoforMaynard/Viscid.svg?branch=master"
</a>

.. _dev: https://github.com/KristoforMaynard/Viscid/tree/dev
.. _html_dev: http://kristoformaynard.github.io/Viscid/docs/dev/index.html
.. _tests_dev: http://kristoformaynard.github.io/Viscid/summary/dev-2.7/index.html
.. _html_dev: http://kristoformaynard.github.io/Viscid-docs/docs/dev/index.html
.. _tests_dev: http://kristoformaynard.github.io/Viscid-docs/summary/dev-2.7/index.html
.. |travis-dev| raw:: html

<a href="https://travis-ci.org/KristoforMaynard/Viscid">
Expand Down
Binary file added resources/.doc_deployment_key.enc
Binary file not shown.
1 change: 1 addition & 0 deletions resources/.doc_deployment_key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9F7yna/qDtqYaHwWpigNXJ3oLfIRK2/sTx6gvLQHSPnWOYv6AXwg2XqMOvRuX/qkyu7rooZwLX1UCw0/KLIIBr2TOGxxUMjjMJLoF1rhEEZbfyYiL5NeWn0yZ3FkmivvQqWnpky5RmkSgTPxvC8GMJqnOJJUBb+HEEKYQuUpWWp7LcAokhVdmTRRVMQh5hBPEru3z6dDMG567r7jxh11faNilKNeimcSHE6AFhvSqhtjlzRETbVBfwzBNXfwYden410erHa7fh2CPLejPh8dS/MuamNJ4X4BOeWqpHkqLZELAlg5ZOmk0VpWtmavhCPAUlziB2w2jXi+KH+Y5ocml [email protected]
2 changes: 1 addition & 1 deletion squash_ghpages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ squash_sha_cache=".ghp_squash_sha"
# access to the repository, and ideally they should know what
# they are doing... this script will do a soft reset and ammend
# a commmit followed by a force push upstream.
repo="[email protected]:KristoforMaynard/Viscid.git"
repo="[email protected]:KristoforMaynard/Viscid-docs.git"

# make sure we're on the dev branch
cd ${root_dir}
Expand Down
6 changes: 4 additions & 2 deletions tests/deploy_test_summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ fi


msg="Automatic summary upload ${branch}:${tags}"
${root_dir}/deploy_ghpages -d "summary/${name}" -m "${msg}" \
${root_dir}/deploy_ghpages -d "summary/${name}" \
-r "KristoforMaynard/Viscid-docs" \
-m "${msg}" \
${sdir}/index.html ${sdir}/plots ${sdir}/ref_plots
echo "Summary page uploaded to http://kristoformaynard.github.io/Viscid/summary/${name}"
echo "Summary page uploaded to http://kristoformaynard.github.io/Viscid-docs/summary/${name}"

0 comments on commit e78c589

Please sign in to comment.