-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.sh
executable file
·51 lines (38 loc) · 1.18 KB
/
deploy.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
#!/bin/bash
if [[ "$TRAVIS_PULL_REQUEST" == "true" ]]; then
echo "This is a pull request. No deployment will be done.";
exit 0;
fi
if [[ "$TRAVIS_BRANCH" != "master" ]]; then
echo "This is not a deployable branch.";
exit 0;
fi
echo "Set up $TRAVIS_REPO_SLUG [via travis] for $GIT_NAME <${GIT_EMAIL}>"
export REPO_URL="https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git"
git config --global user.email "$GIT_EMAIL"
git config --global user.name "$GIT_NAME"
LAST_COMMIT=$(git log --oneline | head -n 1)
# <new_branch> is created if it doesn’t exist; otherwise, it is reset.
git checkout -B gh-pages
echo "=== git status ==="
git status
echo "=== remove unnecessary files for deployment ==="
rm -rf bower_components node_modules css fonts images js docs scss favicons dist
rm -rf .sass-cache
echo "=== move resources to the parent directory ==="
cd _gh_pages
mv *.html ../
mv assets ../
mv downloads ../
cd ..
rm -rf _gh_pages
echo "=== check what files are remaining ==="
ls -la
echo "=== git status ==="
git status
echo "=== git commit ==="
echo "message :" $LAST_COMMIT
git add -A .
git commit -m "Travis build $TRAVIS_BUILD_NUMBER"
echo "=== git push ==="
git push --force $REPO_URL gh-pages