130 lines
3.5 KiB
YAML
130 lines
3.5 KiB
YAML
kind: pipeline
|
||
type: docker
|
||
name: isle-website
|
||
|
||
steps:
|
||
# 恢复缓存
|
||
- name: restore-cache
|
||
pull: if-not-exists # 镜像不存在则拉取,避免多次下载
|
||
image: drillster/drone-volume-cache
|
||
volumes:
|
||
- name: cache
|
||
path: /cache
|
||
settings:
|
||
restore: true
|
||
mount:
|
||
- ./node_modules
|
||
|
||
# 安装依赖
|
||
- name: install
|
||
pull: if-not-exists
|
||
image: node:16.17.1
|
||
commands:
|
||
- echo "安装依赖"
|
||
- echo "全局安装PNPM"
|
||
- npm config set registry https://registry.npmmirror.com/
|
||
- npm install -g pnpm
|
||
- pnpm -v
|
||
- echo "PNPM安装完成"
|
||
- pnpm config get registry
|
||
- pnpm config set registry https://registry.npmmirror.com/
|
||
# - pnpm config set registry http://registry.npm.taobao.org/
|
||
# - pnpm config set registry https://registry.npmjs.org
|
||
- pnpm install --no-frozen-lockfile
|
||
|
||
# 构建
|
||
- name: build
|
||
pull: if-not-exists
|
||
image: node:16.17.1
|
||
commands:
|
||
- echo "开始构建"
|
||
- npm config set registry https://registry.npmmirror.com/
|
||
- npm install -g pnpm
|
||
- pnpm docs:build
|
||
- ls
|
||
|
||
# 更新缓存
|
||
- name: rebuild-cache
|
||
pull: if-not-exists
|
||
image: drillster/drone-volume-cache
|
||
volumes:
|
||
- name: cache
|
||
path: /cache
|
||
settings:
|
||
rebuild: true
|
||
mount:
|
||
- ./node_modules
|
||
|
||
# 上传
|
||
- name: upload
|
||
image: appleboy/drone-scp
|
||
settings:
|
||
host:
|
||
from_secret: ssh_host
|
||
username:
|
||
from_secret: ssh_username
|
||
password:
|
||
from_secret: ssh_password
|
||
target: /srv/nginx/html/isle/website
|
||
source: ./.vitepress/dist/*
|
||
strip_components: 1
|
||
|
||
- name: deploy
|
||
pull: if-not-exists
|
||
image: appleboy/drone-ssh
|
||
settings:
|
||
host:
|
||
from_secret: ssh_host
|
||
username:
|
||
from_secret: ssh_username
|
||
password:
|
||
from_secret: ssh_password
|
||
port: 22
|
||
script:
|
||
- echo "SSH已连接,开始部署"
|
||
- cd /srv/nginx
|
||
- pwd
|
||
- docker restart nginx
|
||
# - cp -r /drone/src/dist/* web
|
||
- echo "部署完成"
|
||
|
||
# 通知
|
||
- name: notify
|
||
pull: if-not-exists
|
||
image: drillster/drone-email
|
||
settings:
|
||
recipients_only: true # 只发送给指定邮件收件人,不默认发送给流水线创建人
|
||
host: smtp.feishu.cn # SMTP服务器 例如 smtp.qq.com
|
||
port: 465 # SMTP服务端口 例如QQ邮箱端口465
|
||
username: 句末科技研发部
|
||
password: Ljc15090683283
|
||
from: develop@sentenceend.com
|
||
recipients:
|
||
- lijianchao@sentenceend.com
|
||
- biankunchao@sentenceend.com
|
||
subject: "DroneCI构建通知!"
|
||
body: |
|
||
DroneCI构建完成!这是一条通知信息,请勿回复!
|
||
|
||
详细信息:
|
||
- 仓库: ${DRONE_REPO}
|
||
- 分支: ${DRONE_BRANCH}
|
||
- 提交SHA值: ${DRONE_COMMIT}
|
||
- 提交作者: ${DRONE_COMMIT_AUTHOR}
|
||
- 提交信息: ${DRONE_COMMIT_MESSAGE}
|
||
- 触发事件: ${DRONE_BUILD_EVENT}
|
||
- 构建状态: ${DRONE_BUILD_STATUS}
|
||
- 开始时间: ${DRONE_BUILD_STARTED}
|
||
- 结束时间: ${DRONE_BUILD_FINISHED}
|
||
success:
|
||
subject: "DroneCI构建成功"
|
||
message: "构建成功!"
|
||
failure:
|
||
subject: "DroneCI构建失败"
|
||
message: "构建失败,请查看日志以了解详细信息!"
|
||
|
||
trigger:
|
||
branch:
|
||
- main
|
||
event:
|
||
- push |