11
This commit is contained in:
51
.drone.yml
51
.drone.yml
@ -1,43 +1,8 @@
|
|||||||
kind: pipeline
|
kind: pipeline # 定义一个管道
|
||||||
type: docker
|
type: docker # 当前管道的类型
|
||||||
name: vite-build
|
name: test # 当前管道的名称
|
||||||
|
steps: # 定义管道的执行步骤
|
||||||
steps:
|
- name: test # 步骤名称
|
||||||
# 1. 安装依赖
|
image: node:latest # 当前步骤使用的镜像
|
||||||
- name: install dependencies
|
commands: # 当前步骤执行的命令
|
||||||
image: node:16
|
- echo 测试drone执行
|
||||||
commands:
|
|
||||||
- npm install
|
|
||||||
|
|
||||||
# 2. 打包 Vite 项目
|
|
||||||
- name: build vite project
|
|
||||||
image: node:16
|
|
||||||
commands:
|
|
||||||
- vite build
|
|
||||||
|
|
||||||
# 3. 将构建产物上传到目标服务器
|
|
||||||
- name: deploy to server
|
|
||||||
image: appleboy/drone-ssh
|
|
||||||
settings:
|
|
||||||
host: 124.220.228.140 # 目标服务器地址
|
|
||||||
username: root # 远程服务器用户名
|
|
||||||
password:
|
|
||||||
from_secret: ssh_password # 从 Drone secrets 中获取 SSH 密码
|
|
||||||
port: 22 # SSH 端口
|
|
||||||
command_timeout: 5m # 执行命令的超时设置
|
|
||||||
script:
|
|
||||||
- cd /home/docker/drone # 进入构建目录
|
|
||||||
- rm -rf /www/wwwroot/show.zguiy.com/dist # 删除旧的构建产物
|
|
||||||
- cp -r /workspace/dist /www/wwwroot/show.zguiy.com/dist # 复制新的构建产物
|
|
||||||
- chmod -R 755 /www/wwwroot/show.zguiy.com/dist # 设置目录权限
|
|
||||||
- systemctl restart nginx # 重启 Nginx(如果使用 Nginx)
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: build-output
|
|
||||||
host:
|
|
||||||
path: /home/docker/drone # 本地构建目录
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
branch:
|
|
||||||
- master
|
|
||||||
event: [ push ]
|
|
43
.drone1.yml
Normal file
43
.drone1.yml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: vite-build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# 1. 安装依赖
|
||||||
|
- name: install dependencies
|
||||||
|
image: node:16
|
||||||
|
commands:
|
||||||
|
- npm install
|
||||||
|
|
||||||
|
# 2. 打包 Vite 项目
|
||||||
|
- name: build vite project
|
||||||
|
image: node:16
|
||||||
|
commands:
|
||||||
|
- vite build
|
||||||
|
|
||||||
|
# 3. 将构建产物上传到目标服务器
|
||||||
|
- name: deploy to server
|
||||||
|
image: appleboy/drone-ssh
|
||||||
|
settings:
|
||||||
|
host: 124.220.228.140 # 目标服务器地址
|
||||||
|
username: root # 远程服务器用户名
|
||||||
|
password:
|
||||||
|
from_secret: ssh_password # 从 Drone secrets 中获取 SSH 密码
|
||||||
|
port: 22 # SSH 端口
|
||||||
|
command_timeout: 5m # 执行命令的超时设置
|
||||||
|
script:
|
||||||
|
- cd /home/docker/drone # 进入构建目录
|
||||||
|
- rm -rf /www/wwwroot/show.zguiy.com/dist # 删除旧的构建产物
|
||||||
|
- cp -r /workspace/dist /www/wwwroot/show.zguiy.com/dist # 复制新的构建产物
|
||||||
|
- chmod -R 755 /www/wwwroot/show.zguiy.com/dist # 设置目录权限
|
||||||
|
- systemctl restart nginx # 重启 Nginx(如果使用 Nginx)
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: build-output
|
||||||
|
host:
|
||||||
|
path: /home/docker/drone # 本地构建目录
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
event: [ push ]
|
Reference in New Issue
Block a user