forked from mhausenblas/mkdocs-deploy-gh-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.sh
43 lines (33 loc) · 1.2 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
#!/bin/bash
set -e
function print_info() {
echo -e "\e[36mINFO: ${1}\e[m"
}
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 "${GITHUB_TOKEN}" ]; then
print_info "setup with GITHUB_TOKEN"
remote_repo="https://x-access-token:${GITHUB_TOKEN}@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.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.com"
fi
git remote rm origin
git remote add origin "${remote_repo}"
mkdocs gh-deploy --config-file "${GITHUB_WORKSPACE}/mkdocs.yml" --force