This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·55 lines (46 loc) · 1.7 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
52
53
54
55
##!/usr/bin/env bash
BRANCH=master
TARGET_REPO=pkking/pkking.github.io.git
PELICAN_OUTPUT_FOLDER=pkking
echo -e "Testing travis-encrypt"
echo -e "$VARNAME"
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS" == "true" ]; then
git config --global user.email "[email protected]"
git config --global user.name "Li Chaoran"
fi
# Using token clone gh-pages branch
# git clone --quiet --branch=$BRANCH https://${GH_TOKEN}@github.com/$TARGET_REPO built_website > /dev/null
# Go into directory and copy data we're interested in to that directory
# cd built_website
# rsync -rv --exclude=.git ../$PELICAN_OUTPUT_FOLDER/* .
# echo -e "Remove previous version of website\n"
# git rm -rf .
# git clean -f -d
# git commit -m "Rel 1.5 - Empty the branch before pushing($TRAVIS_BUILD_NUMBER)"
# git push -fq origin $BRANCH > /dev/null
# cd ..
echo -e "Starting deployment on Github Pages\n"
# Using token clone gh-pages branch
git clone --quiet --branch=$BRANCH https://${GH_TOKEN}@github.com/$TARGET_REPO built_website > /dev/null
if [ $? -ne 0 ];then
echo "fail to clone $TARGET_REPO"
exit 1
fi
# Go into directory and copy data we're interested in to that directory
cd built_website
rsync -artv --exclude=.git ../$PELICAN_OUTPUT_FOLDER/ .
if [ $? -ne 0 ];then
echo "fail to sync $PELICAN_OUTPUT_FOLDER content"
exit 1
fi
# Add, commit and push files
git add -f . &&
git commit -m "commit $TRAVIS_COMMIT pushed to Github Pages" &&
git push -fq origin $BRANCH > /dev/null
if [ $? -ne 0 ];then
echo "fail to push pages to $TARGET_REPO"
exit 1
fi
echo -e "Deploy completed\n"
fi