Files
jdt-game/.drone.yml
YuanHuakk ad5dd9b59f
Some checks failed
continuous-integration/drone/push Build is failing
ci(custom):
2024-03-08 19:33:07 +08:00

171 lines
4.4 KiB
YAML

kind: pipeline
type: docker
name: default
# platform:
# os: linux
# arch: amd64
steps:
- name: 测试服-依赖安装&&编译打包
pull: if-not-exists
image: node:20-alpine
when:
branch:
- test
commands:
- npm config set registry https://registry.npmmirror.com/
- npm install -g pnpm
- pnpm install
- pnpm build:h5:test
- rm -rf dist.tar
- rm -rf node_modules
- tar -zcvf dist.tar ./dist ./default.conf ./Dockerfile
- name: 正式服-依赖安装&&编译打包
pull: if-not-exists
image: node:20-alpine
when:
branch:
- master
commands:
- npm config set registry https://registry.npmmirror.com/
- npm install -g pnpm
- pnpm install
- pnpm build:h5:prod
- rm -rf dist.tar
- rm -rf node_modules
- tar -zcvf dist.tar ./dist ./default.conf ./Dockerfile
- name: 测试服-产物上传
pull: if-not-exists
image: appleboy/drone-scp
when:
branch:
- test
settings:
host:
from_secret: HOST_DEV
username:
from_secret: USER_DEV
password:
from_secret: PWD_DEV
port: 22
strip_components: 1
target: /www/builder
source:
- ./dist.tar
- name: 测试服-部署
pull: if-not-exists
image: appleboy/drone-ssh
when:
branch:
- test
settings:
host:
from_secret: HOST_DEV
username:
from_secret: USER_DEV
password:
from_secret: PWD_DEV
port: 22
script:
- cd /www/builder
- mkdir jdt-tz-dev
- tar -xzvf dist.tar -C /www/builder/jdt-tz-dev
- rm -rf dist.tar
- cd jdt-tz-dev
- docker build -t jdt-tz-dev .
- target_container="jdt-tz-dev"
- if docker ps -a --format '{{.Names}}' | grep -q "^$target_container$"; then
- echo "容器存在,执行操作..."
- docker stop jdt-tz-dev
- docker rm jdt-tz-dev
- else
- echo "容器不存在"
- fi
- docker run -d -p 8283:80 --restart=always --name jdt-tz-dev jdt-tz-dev
- cd ..
- rm -rf jdt-tz-dev
- name: 正式服-产物上传
pull: if-not-exists
image: appleboy/drone-scp
when:
branch:
- master
settings:
host:
from_secret: HOST_PROD
username:
from_secret: USER_PROD
password:
from_secret: PWD_PROD
port: 22
strip_components: 1
target: /www/builder
source:
- ./dist.tar
- name: 正式服-部署
pull: if-not-exists
image: appleboy/drone-ssh
when:
branch:
- master
settings:
host:
from_secret: HOST_PROD
username:
from_secret: USER_PROD
password:
from_secret: PWD_PROD
port: 22
script:
- cd /www/builder
- mkdir jdt-tz-prod
- tar -xzvf dist.tar -C /www/builder/jdt-tz-prod
- rm -rf dist.tar
- cd jdt-tz-prod
- cd docker build -t jdt-tz-prod .
- target_container="jdt-tz-prod"
- if docker ps -a --format '{{.Names}}' | grep -q "^$target_container$"; then
- echo "容器存在,执行操作..."
- docker stop jdt-tz-prod
- docker rm jdt-tz-prod
- else
- echo "容器不存在"
- fi
- docker run -d -p 8283:80 --restart=always --name jdt-tz-prod jdt-tz-prod
- cd ..
- rm -rf jdt-tz-prod
- name: 企业微信通知
pull: if-not-exists
image: plugins/webhook
when:
branch:
- test
- master
status:
- success
- failure
settings:
urls: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a2065e21-4f92-4f5b-a432-2c0cd1d965b5
content_type: application/json
template: |
{
"msgtype": "markdown",
"markdown": {
"content": "{{#success build.status}}✅{{else}}❌{{/success}}**{{ repo.owner }}/{{ repo.name }}** (Build #{{build.number}})\n
>**构建结果**: {{ build.status }}
>**构建详情**: [点击查看]({{ build.link }})
>**代码分支**: {{ build.branch }}
>**提交标识**: {{ build.commit }}
>**提交发起**: {{ build.author }}
>**提交信息**: {{ build.message }}
"
}
}