1331333
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-07-05 20:30:46 +08:00
parent eca130ebcc
commit ce16b3396c
2 changed files with 98 additions and 23 deletions

91
.drone copy 2.yml Normal file
View File

@ -0,0 +1,91 @@
kind: pipeline # 定义一个管道
type: docker # 当前管道的类型
name: test # 当前管道的名称
steps:
# 第一步:构建项目
- name: 构建项目
image: node:18-alpine
commands:
- npm install
- npm run build
volumes:
- name: node_modules_cache
path: /drone/src/node_modules
# 第二步上传静态资源到腾讯云COS (使用另一个插件)
- name: 静态资源上传到cos
image: ccr.ccs.tencentyun.com/xiaoqidun/gocos
settings:
secret_id:
from_secret: cos_secret_id
secret_key:
from_secret: cos_secret_key
bucket_url: https://files-1302416092.cos.ap-shanghai.myqcloud.com
source: dist
target: /test
strip_prefix: dist
# 第三步:部署到服务器
- name: 清除服务器缓存
image: appleboy/drone-ssh
settings:
host:
from_secret: server_host
username:
from_secret: server_username
password:
from_secret: server_password
# 或者使用SSH密钥
# key:
# from_secret: server_ssh_key
port: 22
script:
- rm -rf /www/wwwroot/show.zguiy.com/*
- mkdir -p /www/wwwroot/show.zguiy.com/
- chmod 755 /www/wwwroot/show.zguiy.com/
when:
branch:
- main
- master
- dev
# 第四步:上传构建文件
- name: 上传构建文件
image: appleboy/drone-scp
settings:
host:
from_secret: server_host
username:
from_secret: server_username
password:
from_secret: server_password
# 或者使用SSH密钥
# key:
# from_secret: server_ssh_key
port: 22
source: dist/*
target: /www/wwwroot/show.zguiy.com/
strip_components: 1
when:
branch:
- main
- master
- dev
# 定义数据卷用于缓存node_modules
volumes:
- name: node_modules_cache
host:
path: /tmp/drone_cache/node_modules
# 触发条件
trigger:
branch:
- main
- master
- dev
event:
- push
- pull_request

View File

@ -1,20 +1,16 @@
kind: pipeline # 定义一个管道 kind: pipeline
type: docker # 当前管道的类型 type: docker
name: test # 当前管道的名称 name: test
steps: steps:
# 第一步:构建项目
- name: 构建项目 - name: 构建项目
image: node:18-alpine image: node:18-alpine
commands: commands:
- npm install - rm -rf node_modules
- npm ci
- npm run build - npm run build
volumes:
- name: node_modules_cache
path: /drone/src/node_modules
# 第二步上传静态资源到腾讯云COS (使用另一个插件)
- name: 静态资源上传到cos - name: 静态资源上传到cos
image: ccr.ccs.tencentyun.com/xiaoqidun/gocos image: ccr.ccs.tencentyun.com/xiaoqidun/gocos
settings: settings:
@ -27,7 +23,6 @@ steps:
target: /test target: /test
strip_prefix: dist strip_prefix: dist
# 第三步:部署到服务器
- name: 清除服务器缓存 - name: 清除服务器缓存
image: appleboy/drone-ssh image: appleboy/drone-ssh
settings: settings:
@ -37,9 +32,6 @@ steps:
from_secret: server_username from_secret: server_username
password: password:
from_secret: server_password from_secret: server_password
# 或者使用SSH密钥
# key:
# from_secret: server_ssh_key
port: 22 port: 22
script: script:
- rm -rf /www/wwwroot/show.zguiy.com/* - rm -rf /www/wwwroot/show.zguiy.com/*
@ -51,7 +43,6 @@ steps:
- master - master
- dev - dev
# 第四步:上传构建文件
- name: 上传构建文件 - name: 上传构建文件
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
@ -61,9 +52,6 @@ steps:
from_secret: server_username from_secret: server_username
password: password:
from_secret: server_password from_secret: server_password
# 或者使用SSH密钥
# key:
# from_secret: server_ssh_key
port: 22 port: 22
source: dist/* source: dist/*
target: /www/wwwroot/show.zguiy.com/ target: /www/wwwroot/show.zguiy.com/
@ -74,13 +62,9 @@ steps:
- master - master
- dev - dev
# 定义数据卷用于缓存node_modules # 移除 node_modules 缓存挂载
volumes: # volumes: 已删除
- name: node_modules_cache
host:
path: /tmp/drone_cache/node_modules
# 触发条件
trigger: trigger:
branch: branch:
- main - main