db-tutorial/scripts/deploy.sh

47 lines
1.1 KiB
Bash
Raw Normal View History

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