Files
mol-robot/.drone.yml
mol e43dbcd3b6
All checks were successful
continuous-integration/drone/push Build is passing
test: auto
2023-08-09 12:01:25 +08:00

51 lines
2.0 KiB
YAML

kind: pipeline # 定义一个管道
type: docker # 当前管道的类型
name: build # 当前管道的名称
steps: # 定义管道的执行步骤
# - name: build-project # 步骤名称
# image: node:18-bullseye # 当前步骤使用的镜像
# volumes:
# - name: node_modules
# path: /drone/src/node_modules
# commands: # 当前步骤执行的命令
# - pwd
# - npm config set registry https://registry.npm.taobao.org
# - npm i
- name: build-image
image: plugins/docker
# depends_on: [build-project]
settings:
username:
from_secret: docker_username
password:
from_secret: docker_passwd
dockerfile: Dockerfile
registry: https://git.hiiragi.club:8081
repo: git.hiiragi.club:8081/mol/mirai-robot
- name: deploy-project
image: appleboy/drone-ssh
depends_on: [build-image]
settings:
host:
from_secret: host
username:
from_secret: server_username # 使用secrets
key:
from_secret: server_key
port: 22
command_timeout: 2m
secrets: [docker_username, docker_passwd]
script:
- echo ==-----==开始部署==-----==
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWD git.hiiragi.club:8081
- docker pull git.hiiragi.club:8081/mol/mirai-robot:latest
- list=$(docker ps -a | grep mirai_robot* | awk '{print $1}')
- test "$list" = "" && echo "none mirai_robot containers running" || docker stop $list && docker container rm $list
# 过滤出dockerImages的id, 删除none镜像
- docker run -d -p 16808:8080 --name=mirai_robot_${DRONE_BUILD_NUMBER} -e QQ=3377438428 -e WEB_HOOK_PORT=8080 -e IMG_NUMBER_IN_ONE_MESSAGE=3 -e MIRAI_HTTP_API_HOST=http://192.168.124.12:15122 -e MIRAI_HTTP_API_VERIFY_KEY=heiyu518 git.hiiragi.club:8081/mol/mirai-robot:latest
- docker rmi $(docker images | grep "none" | awk '{print $3}')
- echo ==-----==部署成功==-----==