diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9d7a082 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/.travis/deploy.sh b/.travis/deploy.sh new file mode 100755 index 0000000..0785733 --- /dev/null +++ b/.travis/deploy.sh @@ -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 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 diff --git a/.travis/khs1994-robot.enc b/.travis/khs1994-robot.enc new file mode 100644 index 0000000..f46f6c7 Binary files /dev/null and b/.travis/khs1994-robot.enc differ