-
Notifications
You must be signed in to change notification settings - Fork 236
/
deploy.sh
47 lines (39 loc) · 1.14 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env sh
# ------------------------------------------------------------------------------
# gh-pages 部署脚本
# @author Dunwu
# @since 2020/2/10
# ------------------------------------------------------------------------------
# 装载其它库
ROOT_DIR=$(
cd $(dirname $0)
pwd
)
# 确保脚本抛出遇到的错误
set -e
# 生成静态文件
npm install
npm run build
# 进入生成的文件夹
cd ${ROOT_DIR}/.temp
# 如果是发布到自定义域名
# echo 'www.example.com' > CNAME
if [[ ${GITHUB_TOKEN} && ${GITEE_TOKEN} ]]; then
msg='自动部署'
GITHUB_URL=https://dunwu:${GITHUB_TOKEN}@github.com/dunwu/blog.git
GITEE_URL=https://turnon:${GITEE_TOKEN}@gitee.com/turnon/blog.git
git config --global user.name "dunwu"
git config --global user.email "[email protected]"
else
msg='手动部署'
[email protected]:dunwu/blog.git
[email protected]:turnon/blog.git
fi
git init
git add -A
git commit -m "${msg}"
# 推送到github gh-pages分支
git push -f "${GITHUB_URL}" master:gh-pages
#由于仓库容量超出gitee限制,停止push
#git push -f "${GITEE_URL}" master:gh-pages
rm -rf ${ROOT_DIR}/.temp