-
Notifications
You must be signed in to change notification settings - Fork 8
/
push.sh
executable file
·62 lines (54 loc) · 1.22 KB
/
push.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
57
58
59
60
61
62
#!/bin/sh
setup_git() {
git config --global user.email "[email protected]"
git config --global user.name "Travis CI (on behalf of @ztl8702)"
}
prepare() {
cp -rf ./build /tmp/
}
checkout() {
git remote update
git fetch
git checkout gh-pages
git checkout -b gh-pages-new
git reset --hard origin/gh-pages
}
checkout_pr() {
git checkout gh-pages
git pull
git checkout -b gh-pages-review
}
commit_website_files() {
git rm -r '*'
rm -rf ./*
cp -rf /tmp/build/* ./
git add .
git commit --message "Travis build: $TRAVIS_BUILD_NUMBER"
}
auth() {
git remote add origin-ci https://${GH_TOKEN}@github.com/only3km/ciklinbekin.git > /dev/null 2>&1
}
upload_files() {
git checkout gh-pages
git reset --hard gh-pages-new --
git push --quiet --set-upstream origin-ci --force gh-pages
}
upload_files_pr() {
git push --quiet --set-upstream origin-ci --force gh-pages-review
}
setup_git
auth
prepare
if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
checkout
else
checkout_pr
fi
commit_website_files
if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
upload_files
else
if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then
upload_files_pr
fi
fi