Switch to unified view

a b/.circleci/deploy_docs.bash
1
#!/bin/bash
2
set -eou pipefail
3
4
# References:
5
#  - https://github.com/bioconda/bioconda-utils/blob/master/.circleci/build-docs.sh
6
#  - https://docs.travis-ci.com/user/encrypting-files
7
#  - https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
8
9
# ----------------------------------------------------------------------------
10
#
11
# Repository-specific configuration
12
#
13
# ----------------------------------------------------------------------------
14
15
# Note that the keypair needs to be specific to repo, so if ORIGIN changes, the
16
# keypair (docs/key.enc, and the corresponding public key in the setting of the
17
# repo) need to be updated.
18
BRANCH="master"
19
ORIGIN="kundajelab.github.io"
20
GITHUB_USERNAME="kundajelab"
21
TARGET_FOLDER="bpnet/"
22
23
# DOCSOURCE is directory containing the Makefile, relative to the directory
24
# containing this bash script.
25
DOCSOURCE=`pwd`/docs/
26
27
# DOCHTML is where mkdocs is configured to save the output HTML
28
DOCHTML=$DOCSOURCE/site
29
30
# tmpdir to which built docs will be copied
31
STAGING=/tmp/${GITHUB_USERNAME}-docs
32
33
# Build docs only if ci-runner is testing this branch:
34
BUILD_DOCS_FROM_BRANCH="master"
35
36
# ----------------------------------------------------------------------------
37
#
38
# END repository-specific configuration. The code below is generic; to use for
39
# another repo, edit the above settings.
40
#
41
# ----------------------------------------------------------------------------
42
43
if [[ $CIRCLE_PROJECT_USERNAME != kundajelab ]]; then
44
    echo "$CIRCLE_PROJECT_USERNAME != kundajelab"
45
    exit 1
46
fi
47
48
REPO="git@github.com:${GITHUB_USERNAME}/${ORIGIN}.git"
49
50
# clone the branch to tmpdir, clean out contents
51
rm -rf $STAGING
52
mkdir -p $STAGING
53
54
SHA=$(git rev-parse --verify HEAD)
55
git clone $REPO $STAGING
56
cd $STAGING
57
git checkout $BRANCH || git checkout --orphan $BRANCH
58
# remove the existing target folder
59
rm -rf ${TARGET_FOLDER}
60
61
# copy over the docs to tmpdir
62
cd ${DOCSOURCE}
63
cp -r ${DOCHTML} $STAGING/${TARGET_FOLDER}
64
65
# commit and push
66
cd $STAGING
67
68
# committing with no changes results in exit 1, so check for that case first.
69
# if git diff --quiet; then
70
#    echo "No changes to push -- exiting cleanly"
71
#     exit 0
72
# fi
73
74
# Ignore branch
75
# if [[ $CIRCLE_BRANCH != master ]]; then
76
#     echo "Not pushing docs because not on branch '$BUILD_DOCS_FROM_BRANCH'"
77
#     exit 0
78
# fi
79
80
81
# Add, commit, and push
82
echo ".*" >> .gitignore
83
git config user.name "Circle-CI-kundajelab"
84
git config user.email "${GITHUB_USERNAME}@users.noreply.github.com"
85
git add -A .
86
git commit --all -m "Updated docs to commit ${SHA}."
87
echo "Pushing to $REPO:$BRANCH"
88
git push $REPO $BRANCH &> /dev/null