-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
72 lines (54 loc) · 1.54 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env sh
# 确保脚本抛出遇到的错误
set -e
initDist(){
echo $1 > base.js
}
#------------------------------------------
#url访问目录,这个是你 github 仓库的名字
initDist "module.exports = '/campus-doc/'"
# 生成静态文件
npm run build
# 进入生成的文件夹
cd docs/.vuepress/dist
# deploy to github
if [ -z "$GITHUB_TOKEN" ]; then
# 手动部署
msg='deploy'
githubUrl=git@github.com:oddfar/campus-doc.git
else
# 自动部署
msg='来自github actions的自动部署'
githubUrl=https://oddfar:${GITHUB_TOKEN}@github.com/oddfar/campus-doc.git
git config --global user.name "oddfar"
git config --global user.email "oddfar@163.com"
fi
git init
git add -A
git commit -m "${msg}"
git push -f $githubUrl master:gh-pages # 推送到github
cd - # 退回开始所在目录
rm -rf docs/.vuepress/dist
#------------------------------------------
#打包代码同步到 gitee gh-pages分支
if [ -z "$SSH_PRIVATE_KEY" ]; then
echo '如果是空字符串,则不部署到gitee'
else
#url访问目录
initDist "module.exports = '/'"
# 生成静态文件
npm run build
# 进入生成的文件夹
cd docs/.vuepress/dist
giteeUrl=git@gitee.com:oddfar/notes.git #gitee 仓库ssh地址
git config --global user.name "oddfar"
git config --global user.email "oddfar@163.com"
git init
git add -A
git commit -m "来自github actions的自动部署"
git push -f $giteeUrl master:gh-pages
cd - # 退回开始所在目录
rm -rf docs/.vuepress/dist
# 删除秘钥
rm -rf ~/.ssh
fi