添加drone配置示例

This commit is contained in:
周炽键 2021-06-28 13:52:36 +08:00
parent 651d24ad3b
commit fd85fcef74
2 changed files with 103 additions and 0 deletions

68
.drone.yml Normal file
View File

@ -0,0 +1,68 @@
kind: pipeline
type: exec
name: dev-admin-backend
node:
mode: dev2
trigger:
branch: ci
steps:
- name: inject-file
environment:
ORMCONFIG:
from_secret: ORMCONFIG
ENV:
from_secret: ENV
commands:
- echo -n "$ORMCONFIG" > ormconfig.json
- echo -n "$ENV" > config/.env
- name: build
commands:
- rm package-lock.json || true
- yarn
- yarn build
- export HOME=/root
- pm2 del dev-admin-backend || true
- mkdir /opt/nodewww/dev-admin-backend || rm -rf /opt/nodewww/dev-admin-backend/*
- mv ./* /opt/nodewww/dev-admin-backend
- name: deploy
commands:
- cd /opt/nodewww/express-admin-template
- export OLDHOME=$HOME
- export HOME=/root
- pm2 start -i 0 --name dev-admin-backend ./bin/www
- pm2 startup
- pm2 save
---
kind: pipeline
type: docker
name: dev-admin-backend-builder
node:
mode: dev
trigger:
branch: ci
steps:
- name: build-docker-image
image: plugins/docker
pull: if-not-exists
settings:
username:
from_secret: docker_reg_username
password:
from_secret: docker_reg_password
repo: docker.zcj.plus/zhouchijian/express-admin-template
tags: dev
registry: https://docker.zcj.plus
depends_on:
- dev-admin-backend

35
ci/build_tag.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/sh
if [ "$DRONE_BRANCH" = "ci" ]
then
echo "当前在 ci 分支 正在准备构建dev环境前的工作"
echo -n "dev" > .tags
exit 0
fi;
if [ "$DRONE_BUILD_EVENT" = "tag" ]
then
echo "Git仓库打了标签TAG=$DRONE_TAG正在准备构建prod环境前的工作"
echo -n "$DRONE_TAG" > .tags
echo -n ",latest" >> .tags
exit 0
fi;
echo "DRONE_BRANCH=$DRONE_BRANCH"
echo "DRONE_BUILD_EVENT=$DRONE_BUILD_EVENT"
echo "DRONE_TAG=$DRONE_TAG"
echo "===================不满足构建条件==================="
exit 1;