-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.travis.yml
41 lines (36 loc) · 1.49 KB
/
.travis.yml
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
language: ruby
env:
# directory of Jekyll build artifacts
- OUTPUT_DIR=_site
cache: bundler
branches:
only:
- master
script:
- JEKYLL_ENV=production bundle exec jekyll build --destination $OUTPUT_DIR
# both of the following scripts are deployment scripts:
# in case of pull request, upload build artifacts to preview site;
# otherwise, upload to core site.
before_script:
- |
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
git clone --depth 1 "https://${GITHUB_TOKEN}@github.com/puyotw/puyotw.github.io.git" $OUTPUT_DIR
else
git clone --depth 1 "https://${GITHUB_TOKEN}@github.com/puyotw/preview-site.git"
mkdir preview-site/$TRAVIS_PULL_REQUEST
ln -s "$(pwd)/preview-site/$TRAVIS_PULL_REQUEST" $OUTPUT_DIR
# change config file to generate site with preview-site specific url
sed -i.bak \
"s|^baseurl:.*$|baseurl: \"$TRAVIS_PULL_REQUEST\"|; s|^url:.*$|url: \"https://preview.puyo.tw\"|" \
_config.yml
# remove everything from the output dir in case this build request was re-triggered
rm -fr $OUTPUT_DIR/*
fi
after_success:
- |
cd $OUTPUT_DIR
git config --global user.email "carbuncle-bot-puyotw[bot]@users.noreply.github.com"
git config --global user.name "carbuncle-bot-puyotw[bot]"
git add . > /dev/null
git commit -m "Travis build $TRAVIS_BUILD_NUMBER against commit $TRAVIS_COMMIT. (#$TRAVIS_PULL_REQUEST)" > /dev/null
git push origin master