2020-02-10 14:27:39 +08:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# gh-pages 部署脚本
|
|
|
|
# @author Zhang Peng
|
|
|
|
# @since 2020/2/10
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# 装载其它库
|
2022-04-11 16:51:22 +08:00
|
|
|
ROOT_DIR=$(
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
pwd
|
|
|
|
)
|
2020-02-10 14:27:39 +08:00
|
|
|
|
|
|
|
# 确保脚本抛出遇到的错误
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# 生成静态文件
|
|
|
|
npm run build
|
|
|
|
|
|
|
|
# 进入生成的文件夹
|
2022-04-11 16:51:22 +08:00
|
|
|
cd ${ROOT_DIR}/docs/.temp
|
2020-02-10 14:27:39 +08:00
|
|
|
|
|
|
|
# 如果是发布到自定义域名
|
|
|
|
# echo 'www.example.com' > CNAME
|
|
|
|
|
|
|
|
if [[ ${GITHUB_TOKEN} && ${GITEE_TOKEN} ]]; then
|
2022-04-11 16:51:22 +08:00
|
|
|
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"
|
2020-02-10 14:27:39 +08:00
|
|
|
else
|
2022-04-11 16:51:22 +08:00
|
|
|
msg='手动部署'
|
|
|
|
GITHUB_URL=git@github.com:dunwu/db-tutorial.git
|
|
|
|
GITEE_URL=git@gitee.com:turnon/db-tutorial.git
|
2020-02-10 14:27:39 +08:00
|
|
|
fi
|
2022-04-11 16:51:22 +08:00
|
|
|
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 -
|
|
|
|
rm -rf ${ROOT_DIR}/docs/.temp
|