diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..36b705c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,36 @@ +name: CI + +# 在master分支发生push事件时触发。 +on: + push: + branches: + - master + +env: # 设置环境变量 + TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用时区时间) + +jobs: + build: # 自定义名称 + runs-on: ubuntu-latest # 运行在虚拟机环境ubuntu-latest + + strategy: + matrix: + node-version: [14.x] + + steps: + # 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions + - name: Checkout + uses: actions/checkout@master + + # 指定 nodejs 版本 + - name: Use Nodejs ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + # 部署 + - name: Deploy + env: # 设置环境变量 + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} + run: npm install && npm run deploy diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 47463f9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -# 持续集成 CI -# @see https://docs.travis-ci.com/user/tutorial/ - -language: node_js - -sudo: required - -node_js: '16.13.0' - -branches: - only: - - master - -before_install: - - export TZ=Asia/Shanghai - -script: bash ./scripts/deploy.sh - -notifications: - email: - recipients: - - forbreak@163.com - on_success: change - on_failure: always diff --git a/docs/.markdownlint.json b/docs/.markdownlint.json index 3df31ed..1ab9a8f 100644 --- a/docs/.markdownlint.json +++ b/docs/.markdownlint.json @@ -13,5 +13,6 @@ "MD036": false, "fenced-code-language": false, "no-hard-tabs": false, - "whitespace": false + "whitespace": false, + "emphasis-style": { "style": "consistent" } } diff --git a/docs/package.json b/docs/package.json deleted file mode 100644 index 953d385..0000000 --- a/docs/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "db-tutorial", - "version": "1.0.0", - "private": true, - "scripts": { - "clean": "rimraf dist && rimraf .temp", - "build": "npm run clean && vuepress build ./ --temp .temp", - "start": "vuepress dev ./ --temp .temp", - "lint": "markdownlint -r markdownlint-rule-emphasis-style -c ./.markdownlint.json **/*.md -i node_modules", - "lint:fix": "markdownlint -f -r markdownlint-rule-emphasis-style -c ./.markdownlint.json **/*.md -i node_modules", - "show-help": "vuepress --help", - "view-info": "vuepress view-info ./ --temp .temp" - }, - "devDependencies": { - "@vuepress/plugin-active-header-links": "^1.8.2", - "@vuepress/plugin-back-to-top": "^1.8.2", - "@vuepress/plugin-medium-zoom": "^1.8.2", - "@vuepress/plugin-pwa": "^1.8.2", - "@vuepress/theme-vue": "^1.8.2", - "markdownlint-cli": "^0.30.0", - "markdownlint-rule-emphasis-style": "^1.0.1", - "rimraf": "^3.0.1", - "vue-toasted": "^1.1.25", - "vuepress": "^1.8.2", - "vuepress-plugin-flowchart": "^1.5.0" - }, - "dependencies": { - "moment": "^2.29.1" - } -} diff --git a/package.json b/package.json new file mode 100644 index 0000000..d5c0d8b --- /dev/null +++ b/package.json @@ -0,0 +1,37 @@ +{ + "name": "java-tutorial", + "version": "1.0.0", + "scripts": { + "clean": "rimraf docs/.temp", + "start": "vuepress dev docs", + "build": "vuepress build docs", + "deploy": "bash scripts/deploy.sh", + "updateTheme": "yarn remove vuepress-theme-vdoing && rm -rf node_modules && yarn && yarn add vuepress-theme-vdoing -D", + "editFm": "node utils/editFrontmatter.js", + "lint": "markdownlint -r markdownlint-rule-emphasis-style -c ./.markdownlint.json **/*.md -i node_modules", + "lint:fix": "markdownlint -f -r markdownlint-rule-emphasis-style -c ./.markdownlint.json **/*.md -i node_modules", + "show-help": "vuepress --help", + "view-info": "vuepress view-info ./ --temp docs/.temp" + }, + "license": "MIT", + "devDependencies": { + "dayjs": "^1.9.7", + "inquirer": "^7.1.0", + "json2yaml": "^1.1.0", + "vuepress": "1.9.2", + "vuepress-plugin-baidu-tongji": "^1.0.1", + "vuepress-plugin-demo-block": "^0.7.2", + "vuepress-plugin-fulltext-search": "^2.2.1", + "vuepress-plugin-one-click-copy": "^1.0.2", + "vuepress-plugin-thirdparty-search": "^1.0.2", + "vuepress-plugin-zooming": "^1.1.7", + "vuepress-plugin-flowchart": "^1.4.2", + "vuepress-theme-vdoing": "^1.10.3", + "yamljs": "^0.3.0", + "markdownlint-cli": "^0.25.0", + "markdownlint-rule-emphasis-style": "^1.0.1", + "rimraf": "^3.0.1", + "vue-toasted": "^1.1.25" + }, + "dependencies": {} +} diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..eb6bb1f --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,7 @@ +/** + * @see https://prettier.io/docs/en/options.html + * @see https://prettier.io/docs/en/configuration.html + */ +module.exports = { + tabWidth: 2, semi: false, singleQuote: true +} diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 3596f5e..ba8e17a 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -7,40 +7,40 @@ # ------------------------------------------------------------------------------ # 装载其它库 -ROOT_DIR=$(cd `dirname $0`/..; pwd) +ROOT_DIR=$( + cd $(dirname $0)/.. + pwd +) # 确保脚本抛出遇到的错误 set -e -cd ${ROOT_DIR}/docs - # 生成静态文件 -npm install npm run build # 进入生成的文件夹 -cd dist +cd ${ROOT_DIR}/docs/.temp # 如果是发布到自定义域名 # echo 'www.example.com' > CNAME -git init -git checkout -b gh-pages && git add . -git commit -m 'deploy' - -# 如果发布到 https://.github.io/ -GITHUB_REPO=github.com/dunwu/db-tutorial.git -GITEE_REPO=gitee.com/turnon/db-tutorial.git if [[ ${GITHUB_TOKEN} && ${GITEE_TOKEN} ]]; then - echo "使用 token 公钥部署 gh-pages" - # ${GITHUB_TOKEN} 是 Github 私人令牌;${GITEE_TOKEN} 是 Gitee 私人令牌 - # ${GITHUB_TOKEN} 和 ${GITEE_TOKEN} 都是环境变量;travis-ci 构建时会传入变量 - git push --force --quiet "https://dunwu:${GITHUB_TOKEN}@${GITHUB_REPO}" gh-pages - git push --force --quiet "https://turnon:${GITEE_TOKEN}@${GITEE_REPO}" gh-pages + msg='自动部署' + GITHUB_URL=https://dunwu:${GITHUB_TOKEN}@github.com/dunwu/db-tutorial.git + GITEE_URL=https://turnon:${GITEE_TOKEN}@gitee.com/turnon/db-tutorial.git + git config --global user.name "dunwu" + git config --global user.email "forbreak@163.com" else - echo "使用 ssh 公钥部署 gh-pages" - git push -f git@github.com:dunwu/db-tutorial.git gh-pages - git push -f git@gitee.com:turnon/db-tutorial.git gh-pages + msg='手动部署' + GITHUB_URL=git@github.com:dunwu/db-tutorial.git + GITEE_URL=git@gitee.com:turnon/db-tutorial.git fi +git init +git add -A +git commit -m "${msg}" +# 推送到github gh-pages分支 +git push -f "${GITHUB_URL}" master:gh-pages +git push -f "${GITEE_URL}" master:gh-pages -cd ${ROOT_DIR} +cd - +rm -rf ${ROOT_DIR}/docs/.temp