Skip to content

Commit 106f003

Browse files
committed
build(CI): 弃用 travis-ci,改用 github actions 进行 CI
1 parent b48d146 commit 106f003

File tree

7 files changed

+104
-77
lines changed

7 files changed

+104
-77
lines changed

.github/workflows/deploy.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
# 在master分支发生push事件时触发。
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
env: # 设置环境变量
10+
TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用时区时间)
11+
12+
jobs:
13+
build: # 自定义名称
14+
runs-on: ubuntu-latest # 运行在虚拟机环境ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [14.x]
19+
20+
steps:
21+
# 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions
22+
- name: Checkout
23+
uses: actions/checkout@master
24+
25+
# 指定 nodejs 版本
26+
- name: Use Nodejs ${{ matrix.node-version }}
27+
uses: actions/setup-node@v1
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
31+
# 部署
32+
- name: Deploy
33+
env: # 设置环境变量
34+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
35+
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}
36+
run: npm install && npm run deploy

.travis.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/.markdownlint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"MD036": false,
1414
"fenced-code-language": false,
1515
"no-hard-tabs": false,
16-
"whitespace": false
16+
"whitespace": false,
17+
"emphasis-style": { "style": "consistent" }
1718
}

docs/package.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "java-tutorial",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"clean": "rimraf docs/.temp",
6+
"start": "vuepress dev docs",
7+
"build": "vuepress build docs",
8+
"deploy": "bash scripts/deploy.sh",
9+
"updateTheme": "yarn remove vuepress-theme-vdoing && rm -rf node_modules && yarn && yarn add vuepress-theme-vdoing -D",
10+
"editFm": "node utils/editFrontmatter.js",
11+
"lint": "markdownlint -r markdownlint-rule-emphasis-style -c ./.markdownlint.json **/*.md -i node_modules",
12+
"lint:fix": "markdownlint -f -r markdownlint-rule-emphasis-style -c ./.markdownlint.json **/*.md -i node_modules",
13+
"show-help": "vuepress --help",
14+
"view-info": "vuepress view-info ./ --temp docs/.temp"
15+
},
16+
"license": "MIT",
17+
"devDependencies": {
18+
"dayjs": "^1.9.7",
19+
"inquirer": "^7.1.0",
20+
"json2yaml": "^1.1.0",
21+
"vuepress": "1.9.2",
22+
"vuepress-plugin-baidu-tongji": "^1.0.1",
23+
"vuepress-plugin-demo-block": "^0.7.2",
24+
"vuepress-plugin-fulltext-search": "^2.2.1",
25+
"vuepress-plugin-one-click-copy": "^1.0.2",
26+
"vuepress-plugin-thirdparty-search": "^1.0.2",
27+
"vuepress-plugin-zooming": "^1.1.7",
28+
"vuepress-plugin-flowchart": "^1.4.2",
29+
"vuepress-theme-vdoing": "^1.10.3",
30+
"yamljs": "^0.3.0",
31+
"markdownlint-cli": "^0.25.0",
32+
"markdownlint-rule-emphasis-style": "^1.0.1",
33+
"rimraf": "^3.0.1",
34+
"vue-toasted": "^1.1.25"
35+
},
36+
"dependencies": {}
37+
}

prettier.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @see https://prettier.io/docs/en/options.html
3+
* @see https://prettier.io/docs/en/configuration.html
4+
*/
5+
module.exports = {
6+
tabWidth: 2, semi: false, singleQuote: true
7+
}

scripts/deploy.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,40 @@
77
# ------------------------------------------------------------------------------
88

99
# 装载其它库
10-
ROOT_DIR=$(cd `dirname $0`/..; pwd)
10+
ROOT_DIR=$(
11+
cd $(dirname $0)/..
12+
pwd
13+
)
1114

1215
# 确保脚本抛出遇到的错误
1316
set -e
1417

15-
cd ${ROOT_DIR}/docs
16-
1718
# 生成静态文件
18-
npm install
1919
npm run build
2020

2121
# 进入生成的文件夹
22-
cd dist
22+
cd ${ROOT_DIR}/docs/.temp
2323

2424
# 如果是发布到自定义域名
2525
# echo 'www.example.com' > CNAME
2626

27-
git init
28-
git checkout -b gh-pages && git add .
29-
git commit -m 'deploy'
30-
31-
# 如果发布到 https://<USERNAME>.github.io/<REPO>
32-
GITHUB_REPO=github.com/dunwu/db-tutorial.git
33-
GITEE_REPO=gitee.com/turnon/db-tutorial.git
3427
if [[ ${GITHUB_TOKEN} && ${GITEE_TOKEN} ]]; then
35-
echo "使用 token 公钥部署 gh-pages"
36-
# ${GITHUB_TOKEN} 是 Github 私人令牌;${GITEE_TOKEN} 是 Gitee 私人令牌
37-
# ${GITHUB_TOKEN} 和 ${GITEE_TOKEN} 都是环境变量;travis-ci 构建时会传入变量
38-
git push --force --quiet "https://dunwu:${GITHUB_TOKEN}@${GITHUB_REPO}" gh-pages
39-
git push --force --quiet "https://turnon:${GITEE_TOKEN}@${GITEE_REPO}" gh-pages
28+
msg='自动部署'
29+
GITHUB_URL=https://dunwu:${GITHUB_TOKEN}@github.com/dunwu/db-tutorial.git
30+
GITEE_URL=https://turnon:${GITEE_TOKEN}@gitee.com/turnon/db-tutorial.git
31+
git config --global user.name "dunwu"
32+
git config --global user.email "forbreak@163.com"
4033
else
41-
echo "使用 ssh 公钥部署 gh-pages"
42-
git push -f git@github.com:dunwu/db-tutorial.git gh-pages
43-
git push -f git@gitee.com:turnon/db-tutorial.git gh-pages
34+
msg='手动部署'
35+
GITHUB_URL=git@github.com:dunwu/db-tutorial.git
36+
GITEE_URL=git@gitee.com:turnon/db-tutorial.git
4437
fi
45-
46-
cd ${ROOT_DIR}
38+
git init
39+
git add -A
40+
git commit -m "${msg}"
41+
# 推送到github gh-pages分支
42+
git push -f "${GITHUB_URL}" master:gh-pages
43+
git push -f "${GITEE_URL}" master:gh-pages
44+
45+
cd -
46+
rm -rf ${ROOT_DIR}/docs/.temp

0 commit comments

Comments
 (0)