From bd25138da021fc2c976995ae423da0a65d15bcbd Mon Sep 17 00:00:00 2001 From: zguiy <1415466602@qq.com> Date: Sat, 5 Jul 2025 20:48:24 +0800 Subject: [PATCH] 123 --- .drone copy.yml | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ .drone.yml | 11 ++---- 2 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 .drone copy.yml diff --git a/.drone copy.yml b/.drone copy.yml new file mode 100644 index 0000000..136edad --- /dev/null +++ b/.drone copy.yml @@ -0,0 +1,89 @@ +kind: pipeline # 定义一个管道 +type: docker # 当前管道的类型 +name: test # 当前管道的名称 + +steps: + + # 第一步:构建项目 + - name: 构建项目 + image: node:18-alpine + commands: + - rm -rf node_modules + - npm ci + - npm run build + + # 第二步:上传静态资源到腾讯云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: /utils + 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/utils.zguiy.com/* + - mkdir -p /www/wwwroot/utils.zguiy.com/ + - chmod 755 /www/wwwroot/utils.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/utils.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 diff --git a/.drone.yml b/.drone.yml index 81dd401..2d0b85d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,11 +8,9 @@ steps: - name: 构建项目 image: node:18-alpine commands: - - npm install + - rm -rf node_modules + - npm ci - npm run build - volumes: - - name: node_modules_cache - path: /drone/src/node_modules # 第二步:上传静态资源到腾讯云COS (使用另一个插件) - name: 静态资源上传到cos @@ -74,11 +72,6 @@ steps: - master - dev -# 定义数据卷用于缓存node_modules -volumes: - - name: node_modules_cache - host: - path: /tmp/drone_cache/node_modules # 触发条件 trigger: