add travis

This commit is contained in:
khs1994 2017-09-04 12:47:22 +08:00
parent 3e5e6bcd75
commit b470de0882
3 changed files with 60 additions and 0 deletions

31
.travis.yml Normal file
View File

@ -0,0 +1,31 @@
language: node_js
node_js: stable
cache:
directories:
- "node_modules"
before_install:
- openssl aes-256-cbc -K $encrypted_4514352cb17e_key -iv $encrypted_4514352cb17e_iv
-in .travis/khs1994-robot.enc -out ~/.ssh/id_rsa -d
- chmod 600 ~/.ssh/id_rsa
- git config --global user.name "khs1994-merge-robot"
- git config --global user.email "ai@khs1994.com"
- echo "TZ='Asia/Shanghai'; export TZ" >> ~/.profile
- . ~/.profile
install:
- git ls-files | while read file; do touch -d $(git log -1 --format="@%ct" "$file") "$file"; done
- npm install gitbook -g
- npm install -g gitbook-cli
script:
- gitbook install
- gitbook build
after_success:
- sh .travis/deploy.sh
branches:
only:
- master
env:
global:
- REPO: git@github.com:khs1994-gitbook/docker_practice.git
addons:
ssh_known_hosts:
- github.com

29
.travis/deploy.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
git clone -b gh-pages "$REPO" .deploy_git
- git ls-files | while read file; do touch -d $(git log -1 --format="@%ct" "$file") "$file"; done
if [ ! $? = 0 ];then
#不存在
echo -e "\033[31mINFO\033[0m BRANCH <gh-pages> NOT exist"
mkdir .deploy_git
cd .deploy_git
git init
git remote add origin $REPO
git checkout -b gh-pages
cd ..
else
#存在
echo -e "\033[32mINFO\033[0m BRANCH exist"
rm -rf .deploy_git/*
fi
# Deploy to GitHub and aliyun
cp -r _book/* .deploy_git/
cd .deploy_git
git add .
COMMIT=`date "+%F %T"`
TAG=`date '+%s'`
git commit -m "Travis CI Site updated: $COMMIT"
git push -f origin gh-pages
git tag | tail -10
git tag
git tag $TAG
git push origin $TAG

BIN
.travis/khs1994-robot.enc Normal file

Binary file not shown.