This commit is contained in:
90
.drone copy.yml
Normal file
90
.drone copy.yml
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
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: 上传到腾讯云
|
||||||
|
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: deploy
|
||||||
|
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: upload
|
||||||
|
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
|
21
.drone.yml
21
.drone.yml
@ -3,8 +3,19 @@ type: docker # 当前管道的类型
|
|||||||
name: test # 当前管道的名称
|
name: test # 当前管道的名称
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# 第一步:构建项目
|
# 第一步:克隆代码
|
||||||
- name: 构建
|
- name: 克隆代码
|
||||||
|
image: alpine/git
|
||||||
|
commands:
|
||||||
|
- git clone $DRONE_REMOTE_URL .
|
||||||
|
- git checkout $DRONE_COMMIT
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
# 第二步:构建项目
|
||||||
|
- name: 构建项目
|
||||||
image: node:18-alpine
|
image: node:18-alpine
|
||||||
commands:
|
commands:
|
||||||
- npm install
|
- npm install
|
||||||
@ -14,7 +25,7 @@ steps:
|
|||||||
path: /drone/src/node_modules
|
path: /drone/src/node_modules
|
||||||
|
|
||||||
# 第二步:上传静态资源到腾讯云COS (使用另一个插件)
|
# 第二步:上传静态资源到腾讯云COS (使用另一个插件)
|
||||||
- name: 上传到腾讯云
|
- name: 静态资源上传到cos
|
||||||
image: ccr.ccs.tencentyun.com/xiaoqidun/gocos
|
image: ccr.ccs.tencentyun.com/xiaoqidun/gocos
|
||||||
settings:
|
settings:
|
||||||
secret_id:
|
secret_id:
|
||||||
@ -27,7 +38,7 @@ steps:
|
|||||||
strip_prefix: dist
|
strip_prefix: dist
|
||||||
|
|
||||||
# 第三步:部署到服务器
|
# 第三步:部署到服务器
|
||||||
- name: deploy
|
- name: 清楚服务器缓存
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
@ -51,7 +62,7 @@ steps:
|
|||||||
- dev
|
- dev
|
||||||
|
|
||||||
# 第四步:上传构建文件
|
# 第四步:上传构建文件
|
||||||
- name: upload
|
- name: 上传构建文件
|
||||||
image: appleboy/drone-scp
|
image: appleboy/drone-scp
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
|
Reference in New Issue
Block a user