-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync.sh
56 lines (45 loc) · 993 Bytes
/
sync.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
#!/usr/bin/env bash
set -e
rm -rf sync
main() {
git log -1 --pretty=%B | cat |
if read -r MESSAGE
then
echo "last commit message:"
echo "$MESSAGE"
local CREATED=1
{
git clone https://user:$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git sync -b gh-pages
} || {
echo "branch \`gh-pages\` has not been created"
CREATED=0
mkdir sync
cd sync
git init
git checkout -b gh-pages
git remote add origin https://user:$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git
cd ..
}
rm -rf sync/*
cd sync
cp -rf ../dist/* .
cp ../*.md .
git add -A
git status -s |
if read
then
git commit -m "$MESSAGE"
if [ "$CREATED" == "1" ]
then
git push --quiet
else
echo "first push, create \`gh-pages\` branch"
git push --quiet --set-upstream origin gh-pages
fi
else
echo "there is nothing changed to commit"
fi
rm -rf sync
fi
}
main