-
Notifications
You must be signed in to change notification settings - Fork 2
/
push_docs.sh
executable file
·54 lines (41 loc) · 1.5 KB
/
push_docs.sh
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
#!/bin/bash
## Commit and publish to website
## @sbamin
## commit message as the first argument
REPO="code101"
WEBURL="https://code.sbamin.com"
WEB_BRANCH="www"
DOCDIR="$HOME"/sync/dbsa/acad/scripts/github/webpages/live/"${REPO}"
WEBDIR="/tmp/${REPO}"
mkdir -p "${WEBDIR}"
#### DANGER ####
## MAKE SURE TO HAVE VALID PATH HERE AS SCRIPT WILL NOT CHECK FOR PATH
## rsync may overwrite or worse, delete files on remote node.
if [[ ! -d "$DOCDIR" || ! -x "$DOCDIR" || ! -x "$WEBDIR" ]]; then
echo -e "\nERROR: DOCDIR does not exists or not accesible at $DOCDIR OR\nWEBDIR does not exists or not accesible at $WEBDIR\n" >&2
exit 1
fi
#### Activate CONDA in subshell ####
## Read https://github.com/conda/conda/issues/7980
CONDA_BASE=$(conda info --base) && \
source "${CONDA_BASE}"/etc/profile.d/conda.sh && \
conda activate ruby
#### END CONDA SETUP ####
## strict check
set -euo pipefail
## build www ##
cd "${DOCDIR}"/web && \
echo "Start building ${REPO}..."
## build docs
rm -rf "${WEBDIR}" && \
mkdir -p "${WEBDIR}" && \
mkdocs build --clean --site-dir "${WEBDIR}" && echo -e "\nINFO: Built updated docs for ${REPO}\n" && \
mkdocs gh-deploy --remote-branch "${WEB_BRANCH}" --clean --site-dir "${WEBDIR}" -m "published commit: {sha} and mkdocs {version}" && \
echo "Successfully updated ${WEBURL} to ${REPO}:${WEB_BRANCH}"
# ## versioning ##
# ## unstable
# mike list --branch www
# mike deploy --branch www --push --update-aliases 1.1 latest
# ## mike set-default -b www --push latest
# mike list --branch www
## END ##