-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdocker-entrypoint.sh
executable file
·80 lines (56 loc) · 2.01 KB
/
docker-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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env sh
set -e
PLAIN='\033[0m'
BOLD='\033[1;37m'
if [ "${INPUT_HUGOVERSION}" ]; then
echo -e "\n${BOLD}Using Hugo version ${INPUT_HUGOVERSION}.${PLAIN}"
wget "https://github.com/gohugoio/hugo/releases/download/v$(echo "${INPUT_HUGOVERSION}" | grep -o "[0-9]\+.[0-9]\+.[0-9]\+")/hugo_${INPUT_HUGOVERSION}_Linux-64bit.tar.gz"
tar x -zvf hugo*.tar.gz
mv hugo /usr/bin/hugo
rm hugo*.tar.gz
fi
if [ "${INPUT_CNAME}" ]; then
NAME=${INPUT_CNAME}
else
NAME=${GITHUB_REPOSITORY}
fi
if [ "${INPUT_REPO}" ]; then
REPO=${INPUT_REPO}
else
REPO=${GITHUB_REPOSITORY}
fi
CD=${INPUT_SITEDIR:=$(pwd)}
[ -z "${INPUT_GITHUBTOKEN}" ] && \
(echo -e "\n${BOLD}ERROR: Missing githubToken.${PLAIN}" ; exit 1)
echo -e "\n${BOLD}Versions:${PLAIN}"
echo -ne "${BOLD}Hugo: ${PLAIN}"
hugo version
echo -ne "${BOLD}Pygments: ${PLAIN}"
pygmentize -V
echo -ne "${BOLD}Asciidoctor: ${PLAIN}"
asciidoctor --version
echo -ne "${BOLD}PostCSS: ${PLAIN}"
postcss --version
echo -ne "${BOLD}Pandoc: ${PLAIN}"
pandoc -v
echo -ne "${BOLD}Babel: ${PLAIN}"
babel --version
echo -e "\n${BOLD}Setting up Git${PLAIN}"
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
echo "machine github.com login ${GITHUB_ACTOR} password ${INPUT_GITHUBTOKEN}" > ~/.netrc
git clone --depth=1 --single-branch --branch "${INPUT_BRANCH}" "https://x-access-token:${INPUT_GITHUBTOKEN}@github.com/${REPO}.git" /tmp/gh-pages
rm -rf /tmp/gh-pages/*
echo -e "\n${BOLD}Generating Site ${NAME} at commit ${GITHUB_SHA}${PLAIN}"
cd ${CD}
hugo mod get
hugo ${INPUT_ARGS} -d /tmp/gh-pages/
echo -e "\n${BOLD}Commiting${PLAIN}"
cd /tmp/gh-pages
[ -n "${INPUT_CNAME}" ] && \
echo "${INPUT_CNAME}" > CNAME
git add -A && git commit --allow-empty -am "Publishing Site ${NAME} at ${GITHUB_SHA} on $(date -u)"
echo -e "\n${BOLD}Pushing${PLAIN}"
git push --force
echo -e "\n${BOLD}Site ${NAME} at ${GITHUB_SHA} was successfully deployed!${PLAIN}"