-
Notifications
You must be signed in to change notification settings - Fork 14
/
entrypoint.sh
executable file
·52 lines (41 loc) · 1.39 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
#!/bin/bash
: "${INPUT_DRY_RUN:=false}"
set -e
echo "REPO: $GITHUB_REPOSITORY"
echo "ACTOR: $GITHUB_ACTOR"
echo "==> Preparing..."
if ! $INPUT_DRY_RUN; then
src_branch="$(python -c 'import conf; print(conf.GITHUB_SOURCE_BRANCH)')"
dest_branch="$(python -c 'import conf; print(conf.GITHUB_DEPLOY_BRANCH)')"
git config --global --add safe.directory /github/workspace
git remote add ghpages "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git fetch ghpages $dest_branch
git checkout -b $dest_branch --track ghpages/$dest_branch || true
git pull ghpages $dest_branch || true
git checkout $src_branch
# Override config so that ghp-import does the right thing.
printf '\n\nGITHUB_REMOTE_NAME = "ghpages"\nGITHUB_COMMIT_SOURCE = False\n' >> conf.py
else
echo "Dry-run, skipping..."
fi
echo "==> Installing requirements..."
if [[ -f "requirements.txt" ]]; then
# Since people might type just 'nikola', we force ghp-import to be installed.
pip install -r requirements.txt ghp-import
else
pip install "Nikola[extras]"
fi
if [[ "x${INPUT_APT_INSTALL}" != "x" ]]; then
apt-get update
apt-get install -y ${INPUT_APT_INSTALL}
apt-get clean
fi
echo "==> Building site..."
nikola build
echo "==> Publishing..."
if ! $INPUT_DRY_RUN; then
nikola github_deploy
else
echo "Dry-run, skipping..."
fi
echo "==> Done!"