-
Notifications
You must be signed in to change notification settings - Fork 5
/
vuepress-webhook.sh
40 lines (38 loc) · 1.14 KB
/
vuepress-webhook.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
#!/bin/ash
set -eo pipefail
if [ -n "$GITHUB_REPO" ]; then
mkdir -p /root/html
cd /root/src
rm -rf ..?* .[!.]* *
if [ -n "$GITHUB_TOKEN" ]; then
git clone https://$GITHUB_TOKEN@$GITHUB_REPO .; git pull
else
git clone https://$GITHUB_REPO .; git pull
fi
vuepress build || (echo "Build failed. Aborting!"; exit 1)
echo "Copying files..."
rsync -q -r --delete .vuepress/dist/ /root/html/
echo "Done!"
if [ -n "$GITHUB_PUSH_REPO" ]; then
if [ -n "$GITHUB_PUSH_TOKEN" ]; then
PUSH_TOKEN=$GITHUB_PUSH_TOKEN
else
if [ -z "$GITHUB_TOKEN" ]; then
echo "No tokens set for pushing."
exit 1
fi
PUSH_TOKEN=$GITHUB_TOKEN
fi
echo "Pushing to Github..."
cd .vuepress/dist
git init
git add -A
git config --global user.email "[email protected]"
git config --global user.name "Vuepress Autobuild"
git commit -m 'Auto Deploy'
git remote add origin https://$PUSH_TOKEN@$GITHUB_PUSH_REPO
git push -f origin master
fi
else
sh /generate.sh
fi