forked from Tiryoh/actions-mkdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·38 lines (30 loc) · 1.11 KB
/
entrypoint.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
#!/bin/bash
set -e
function print_info() {
echo -e "\e[36mINFO: ${1}\e[m"
}
if [ ! -f ${GITHUB_WORKSPACE}/poetry.lock ]; then
cp /docs/poetry.lock ${GITHUB_WORKSPACE}/poetry.lock
fi
if [ ! -f ${GITHUB_WORKSPACE}/pyproject.toml ]; then
cp /docs/pyproject.toml ${GITHUB_WORKSPACE}/pyproject.toml
fi
if [ -n "${INPUT_REQUIREMENTS}" ] && [ -f "${GITHUB_WORKSPACE}/${INPUT_REQUIREMENTS}" ]; then
grep ^[^#] ${GITHUB_WORKSPACE}/${INPUT_REQUIREMENTS} | xargs poetry add || \
pip install -r ${GITHUB_WORKSPACE}/${INPUT_REQUIREMENTS}
fi
if [ -n "${INPUT_MKDOCS_VERSION}" ]; then
if [ ! "${INPUT_MKDOCS_VERSION}" == "latest" ]; then
poetry add mkdocs==${INPUT_MKDOCS_VERSION}
fi
fi
if [ -n "${INPUT_CONFIGFILE}" ]; then
print_info "Setting custom path for mkdocs config yml"
export CONFIG_FILE="${GITHUB_WORKSPACE}/${INPUT_CONFIGFILE}"
else
export CONFIG_FILE="${GITHUB_WORKSPACE}/mkdocs.yml"
fi
# workaround, see https://github.com/actions/checkout/issues/766
git config --global --add safe.directory "$GITHUB_WORKSPACE"
cd ${GITHUB_WORKSPACE}
mkdocs build --config-file ${CONFIG_FILE}