Skip to content

Commit

Permalink
independent 3.21.06.doc branch、adjust travis.yml deploy.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
wenyh1 committed Sep 26, 2023
1 parent ad92255 commit 7ce0a49
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 38 deletions.
57 changes: 29 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dist: trusty
env:
global:
- GH_REF: github.com/actiontech/dble-docs-cn
- GH_USER: actiontech-bot
- GH_MAIL: github@actionsky.com
global:
- GH_REF: github.com/actiontech/dble-docs-cn
- GH_USER: actiontech-bot
- GH_MAIL: github@actionsky.com

# 指定环境语言
language: node_js
Expand All @@ -27,38 +27,39 @@ notifications:
# 构建的分支
branches:
only:
- master

- master
- develop
- /^[0-9]{1}.[0-9]{2}.[0-9]{2}.doc$/ #eg: 2.20.04.doc
# 调整时区
before_install:
- export TZ='Asia/Shanghai'
- sudo apt-get install -y calibre fonts-arphic-gbsn00lp

# 安装环境
install:
- npm install -g gitbook-cli
- npm install -g gitbook-cli
- npm install gitbook-plugin-yahei
- gitbook install

# gitbook生成静态文件
script:
- gitbook build
- cd ./_book
- git init
- git config user.name "${GH_USER}"
- git config user.email "${GH_MAIL}"
- git add .
- git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
- git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages
- cd ..
# pdf
- xvfb-run gitbook pdf ./ ./dble-manual.pdf
- mkdir pdf
- cp dble-manual.pdf ./pdf/
- cd ./pdf
- git init
- git config user.name "${GH_USER}"
- git config user.email "${GH_MAIL}"
- git add .
- git commit -m "Update GitBook By TravisCI With Build PDF $TRAVIS_BUILD_NUMBER"
- git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:pdf
deploy:
# deploy develop to the staging environment
- provider: script
skip_cleanup: true
script: bash ./deploy.sh develop 1 ${GH_TOKEN} $TRAVIS_BUILD_NUMBER
on:
branch: develop
# deploy master to production
- provider: script
skip_cleanup: true
script: bash ./deploy.sh master 1 ${GH_TOKEN} $TRAVIS_BUILD_NUMBER
on:
branch: master
#branch eg: 2.20.04.doc
- provider: script
skip_cleanup: true
script: bash ./deploy.sh $TRAVIS_BRANCH 1 ${GH_TOKEN} $TRAVIS_BUILD_NUMBER
on:
all_branches: true
condition: $TRAVIS_BRANCH =~ ^[0-9]{1}.[0-9]{2}.[0-9]{2}.doc$
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


## 注意
本分支上的手册适用于3.21.06.0版dble,其他版本的文档请参考对应tag分支或者release版文档。
本分支上的手册适用于3.21.06.x版dble,其他版本的文档请参考对应tag分支或者release版文档。

## 提示
[如果您使用了dble,请告诉我们。](https://wj.qq.com/s/2291106/09f4)
Expand Down
21 changes: 12 additions & 9 deletions book.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"plugins": ["expandable-chapters", "splitter", "back-to-top-button","github","popup"],
"plugins": ["expandable-chapters", "splitter", "back-to-top-button","github","popup","versions-select"],
"pluginsConfig": {
"fontsettings": {
"theme": "sepia",
"family": "sans",
"size": 2
},
"github":{
"url":"https://github.com/actiontech/dble"
},
"plugins": [
"yahei",
"katex",
"-search"
]
"versions": {
"gitbookConfigURL": "https://raw.githubusercontent.com/actiontech/dble-docs-cn/master/book.json"
},
"github":{
"url":"https://github.com/actiontech/dble"
},
"plugins": [
"yahei",
"katex",
"-search"
]
},
"styles": {
"website": "website.css",
Expand Down
107 changes: 107 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/bin/bash
set -e

VERSION="$1"
DEPLOY="$2"
GH_TOKEN="$3"
TRAVIS_BUILD_NUMBER="$4"


GH_REF="github.com/actiontech/dble-docs-cn"
GH_USER="actiontech-bot"
GH_MAIL="github@actionsky.com"

reg='^[0-9]{1}\.[0-9]{2}\.[0-9]{2}\.doc$' #eg: 2.20.04.doc
if [ "$VERSION" = "master" ]; then
# pdf
# xvfb-run gitbook pdf ./ ./dble-manual.pdf
mkdir -p _book/history/develop
# merge history—pages
mkdir _old_book
cd ./_old_book
COMMAND_LINE="git clone -b history-pages https://${GH_REF}.git"
eval "$COMMAND_LINE"
cd dble-docs-cn
git archive history-pages | tar -x -C ../../_book/history/
cd ../..
# merge develop—pages
mkdir _develop_book
cd ./_develop_book
COMMAND_LINE="git clone -b develop-pages https://${GH_REF}.git"
eval "$COMMAND_LINE"
cd dble-docs-cn
git archive develop-pages | tar -x -C ../../_book/history/develop/
#deploy
if [ "$DEPLOY" = "1" ]; then
cd ../../_book
git init
git config user.name "${GH_USER}"
git config user.email "${GH_MAIL}"
git add .
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" master:gh-pages
fi

elif [ "$VERSION" = "develop" ]; then
# merge master—pages
mkdir _master_book
cd ./_master_book
COMMAND_LINE="git clone -b gh-pages https://${GH_REF}.git"
eval "$COMMAND_LINE"
rm -rf dble-docs-cn/history/develop/
cd ..
cp -R _book/ _master_book/dble-docs-cn/history/develop/
#deploy to develop—pages
if [ "$DEPLOY" = "1" ]; then
# push gh-pages
cd ./_master_book/dble-docs-cn
git add .
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" gh-pages:gh-pages
# push develop—pages
cd ../../_book
git init
git config user.name "${GH_USER}"
git config user.email "${GH_MAIL}"
git add .
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" master:develop-pages
fi
elif [[ "$VERSION" =~ $reg ]]; then
mkdir _old_book
cd ./_old_book
COMMAND_LINE="git clone -b history-pages https://${GH_REF}.git"
eval "$COMMAND_LINE"
rm -rf dble-docs-cn/$VERSION
cd ..
cp -R _book/ _old_book/dble-docs-cn/$VERSION
cd _old_book/dble-docs-cn/$VERSION
rm -rf .gitignore .travis.yml deploy.sh package-lock.json

cd ../../..
mkdir _master_book
cd ./_master_book
COMMAND_LINE="git clone -b gh-pages https://${GH_REF}.git"
eval "$COMMAND_LINE"
rm -rf dble-docs-cn/history/$VERSION/
cd ..
cp -R _book/ _master_book/dble-docs-cn/history/$VERSION/
cd _master_book/dble-docs-cn/history/$VERSION/
rm -rf .gitignore .travis.yml deploy.sh package-lock.json
cd ../../../..

## push
if [ "$DEPLOY" = "1" ]; then
cd ./_old_book/dble-docs-cn ##history-pages
git add .
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" history-pages:history-pages
cd ../../
cd ./_master_book/dble-docs-cn ##gh-pages
git add .
git commit -m "Update GitBook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}.git" gh-pages:gh-pages
fi
else
echo "do nothing"
fi

0 comments on commit 7ce0a49

Please sign in to comment.