forked from mhausenblas/mkdocs-deploy-gh-pages
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.sh
executable file
·53 lines (42 loc) · 1.53 KB
/
action.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
#!/bin/bash
set -e
function print_info() {
echo -e "\e[36mINFO: ${1}\e[m"
}
if [ -n "${EXTRA_PACKAGES}" ]; then
apk add --no-cache "${EXTRA_PACKAGES}"
fi
if [ -n "${REQUIREMENTS}" ] && [ -f "${GITHUB_WORKSPACE}/${REQUIREMENTS}" ]; then
pip install -r "${GITHUB_WORKSPACE}/${REQUIREMENTS}"
else
REQUIREMENTS="${GITHUB_WORKSPACE}/requirements.txt"
if [ -f "${REQUIREMENTS}" ]; then
pip install -r "${REQUIREMENTS}"
fi
fi
if [ -n "${CUSTOM_DOMAIN}" ]; then
print_info "Setting custom domain for github pages"
echo "${CUSTOM_DOMAIN}" > "${GITHUB_WORKSPACE}/docs/CNAME"
fi
if [ -n "${CONFIG_FILE}" ]; then
print_info "Setting custom path for mkdocs config yml"
export CONFIG_FILE="${GITHUB_WORKSPACE}/${CONFIG_FILE}"
else
export CONFIG_FILE="${GITHUB_WORKSPACE}/mkdocs.yml"
fi
if [ -n "${GITHUB_TOKEN}" ]; then
print_info "setup with GITHUB_TOKEN"
remote_repo="https://x-access-token:${GITHUB_TOKEN}@${GITHUB_DOMAIN:-"github.com"}/${GITHUB_REPOSITORY}.git"
elif [ -n "${PERSONAL_TOKEN}" ]; then
print_info "setup with PERSONAL_TOKEN"
remote_repo="https://x-access-token:${PERSONAL_TOKEN}@${GITHUB_DOMAIN:-"github.com"}/${GITHUB_REPOSITORY}.git"
fi
if ! git config --get user.name; then
git config --global user.name "${GITHUB_ACTOR}"
fi
if ! git config --get user.email; then
git config --global user.email "${GITHUB_ACTOR}@users.noreply.${GITHUB_DOMAIN:-"github.com"}"
fi
git remote rm origin
git remote add origin "${remote_repo}"
mkdocs gh-deploy --config-file "${CONFIG_FILE}" --force