-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·53 lines (38 loc) · 1.25 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env sh
set -e
NC='\e[0m'
BOLD='\e[1m'
UNDERLINE='\e[4m'
BRED='\e[1;4;31m'
IRED='\e[3;31m'
BGREEN='\e[1;32m'
if [ -z "${INPUT_GITHUBTOKEN}" ]; then
echo -e "${BRED}Error:\n${NC} ${IRED}Missing Github Access Token${NC}"
exit 1
fi
if [ "${INPUT_REPO}" ]; then
REPO=${INPUT_REPO}
else
REPO=${GITHUB_REPOSITORY}
fi
REPO_URL="https://x-access-token:${INPUT_GITHUBTOKEN}@github.com/${REPO}.git"
echo -e "${UNDERLINE}Resume${NC}"
echo -e "${BOLD}REPO:${NC} ${REPO}"
echo -e "${BOLD}BRANCH:${NC} ${INPUT_BRANCH}"
[ -n "${INPUT_CNAME}" ] && echo -e "${BOLD}CNAME:${NC} ${INPUT_CNAME}"
echo -e "\n${BOLD}Setting up Git${NC}..."
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
echo "machine github.com login ${GITHUB_ACTOR} password ${INPUT_GITHUBTOKEN}" > ~/.netrc
echo -e "\nBuilding.."
git clone --depth=1 --single-branch --branch "${INPUT_BRANCH}" "${REPO_URL}" /tmp/build
rm -rf /tmp/build/*
cobalt build
cp -a build/* /tmp/build
cd /tmp/build
[ -n "${INPUT_CNAME}" ] && echo "${INPUT_CNAME}" > CNAME
echo -e " \b${BGREEN}[OK]${NC}"
echo -e "\n\nPuching..."
git add -A && git commit --allow-empty -am "Publishing site at $(date -u)"
git push --force
echo -e " \b${BGREEN}[OK]${NC}"