forked from zbrox/zola-deploy-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·53 lines (39 loc) · 1.17 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
#!/bin/bash
set -e
set -o pipefail
if [[ -n "$TOKEN" ]]; then
GITHUB_TOKEN=$TOKEN
fi
if [[ -z "$PAGES_BRANCH" ]]; then
PAGES_BRANCH="gh-pages"
fi
if [[ -z "$GITHUB_TOKEN" ]]; then
echo "Set the GITHUB_TOKEN env variable."
exit 1
fi
if [[ -z "$GITHUB_REPOSITORY" ]]; then
echo "Set the GITHUB_REPOSITORY env variable."
exit 1
fi
main() {
echo "Starting deploy..."
echo "Fetching themes"
git config --global url."https://".insteadOf git://
git config --global url."https://github.com/".insteadOf [email protected]:
git submodule update --init --recursive
version=$(zola --version)
remote_repo="https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_branch=$PAGES_BRANCH
echo "Using $version"
zola build
echo "Pushing artifacts to ${GITHUB_REPOSITORY}:$remote_branch"
cd public
git init
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git commit -m "Deploy ${GITHUB_REPOSITORY} to ${GITHUB_REPOSITORY}:$remote_branch"
git push --force "${remote_repo}" master:${remote_branch}
echo "Deploy complete"
}
main "$@"