[d45a3a]: / .circleci / deploy_docs.bash

Download this file

89 lines (70 with data), 2.6 kB

 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
set -eou pipefail
# References:
# - https://github.com/bioconda/bioconda-utils/blob/master/.circleci/build-docs.sh
# - https://docs.travis-ci.com/user/encrypting-files
# - https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
# ----------------------------------------------------------------------------
#
# Repository-specific configuration
#
# ----------------------------------------------------------------------------
# Note that the keypair needs to be specific to repo, so if ORIGIN changes, the
# keypair (docs/key.enc, and the corresponding public key in the setting of the
# repo) need to be updated.
BRANCH="master"
ORIGIN="kundajelab.github.io"
GITHUB_USERNAME="kundajelab"
TARGET_FOLDER="bpnet/"
# DOCSOURCE is directory containing the Makefile, relative to the directory
# containing this bash script.
DOCSOURCE=`pwd`/docs/
# DOCHTML is where mkdocs is configured to save the output HTML
DOCHTML=$DOCSOURCE/site
# tmpdir to which built docs will be copied
STAGING=/tmp/${GITHUB_USERNAME}-docs
# Build docs only if ci-runner is testing this branch:
BUILD_DOCS_FROM_BRANCH="master"
# ----------------------------------------------------------------------------
#
# END repository-specific configuration. The code below is generic; to use for
# another repo, edit the above settings.
#
# ----------------------------------------------------------------------------
if [[ $CIRCLE_PROJECT_USERNAME != kundajelab ]]; then
echo "$CIRCLE_PROJECT_USERNAME != kundajelab"
exit 1
fi
REPO="git@github.com:${GITHUB_USERNAME}/${ORIGIN}.git"
# clone the branch to tmpdir, clean out contents
rm -rf $STAGING
mkdir -p $STAGING
SHA=$(git rev-parse --verify HEAD)
git clone $REPO $STAGING
cd $STAGING
git checkout $BRANCH || git checkout --orphan $BRANCH
# remove the existing target folder
rm -rf ${TARGET_FOLDER}
# copy over the docs to tmpdir
cd ${DOCSOURCE}
cp -r ${DOCHTML} $STAGING/${TARGET_FOLDER}
# commit and push
cd $STAGING
# committing with no changes results in exit 1, so check for that case first.
# if git diff --quiet; then
# echo "No changes to push -- exiting cleanly"
# exit 0
# fi
# Ignore branch
# if [[ $CIRCLE_BRANCH != master ]]; then
# echo "Not pushing docs because not on branch '$BUILD_DOCS_FROM_BRANCH'"
# exit 0
# fi
# Add, commit, and push
echo ".*" >> .gitignore
git config user.name "Circle-CI-kundajelab"
git config user.email "${GITHUB_USERNAME}@users.noreply.github.com"
git add -A .
git commit --all -m "Updated docs to commit ${SHA}."
echo "Pushing to $REPO:$BRANCH"
git push $REPO $BRANCH &> /dev/null