-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
67 lines (61 loc) · 2.2 KB
/
.gitlab-ci.yml
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
image: mirror.docker.mintimate.cc/my_center/my-node:latest
cache: # 设置缓存
paths:
- .vitepress/dist/ # 缓存生成出来的文件目录
stages: # 全部的步骤
- build
- deploy
- refresh
- message
build-job: # 打包阶段
stage: build
rules:
- if: '$CI_COMMIT_REF_NAME == "main"'
script:
- echo "设置国内更新源"
- npm config set registry http://mirrors.cloud.tencent.com/npm/ # 设置国内源
- echo "执行依赖的更新"
- npm install
- echo "执行打包操作"
- npm run build
deploy-job: # 部署阶段
stage: deploy
rules:
- if: '$CI_COMMIT_REF_NAME == "main"'
script:
- echo "开始部署……"
- echo "设置SSH无感验证"
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- echo "SCP传输"
- ssh-add <(echo "$MINE_SERVER_KEY")
- rsync -r --delete .vitepress/dist/ ${MINE_SERVER_USER}@${MINE_SERVER_IP}:${MINE_SERER_PATH}
- echo "应用部署完成!"
refresh: # 刷新 EO 缓存
stage: refresh
rules:
- if: '$CI_COMMIT_REF_NAME == "main"'
image: mirror.docker.mintimate.cc/my_center/refresh-eo:latest
script:
- echo "刷新 EO 缓存……"
- export SECRET_ID=$TENCENT_SECRET_ID
- export SECRET_KEY=$TENCENT_SECRET_KEY
- export ZONE_ID=$EO_ZONE_ID
- export DOMAIN=$EO_DOMAIN
- export RUN_MODE="cache"
- export SLEEP_TIME=20
- python3 /app/scanSiteMap.py -s .vitepress/dist/sitemap.xml
- echo "EO 缓存刷新完成(●'◡'●)ノ♥!"
message: # 部署成功通知
stage: message
rules:
- if: '$CI_COMMIT_REF_NAME == "main"'
image: mirror.docker.mintimate.cc/my_center/my-wechat-com-push:latest
script:
- echo "发送部署成功的信息……"
- cd /app
- echo "构建SHA:\ ${CI_COMMIT_SHA}"
- python3 main.py -s $MINE_WECHAT_COM -m "时间:\ $(date +%Y-%m-%d)\n构建SHA:\ ${CI_COMMIT_SHA}\n\n薄荷输入法文档构建、推送部署成功\n\(◎◎)/"
- echo "消息推送完成(●'◡'●)ノ♥!"