-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.yml
86 lines (79 loc) · 2.24 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
kind: pipeline
type: docker
name: deploy-server
platform:
os: linux
arсh: amd64
steps:
- name: build-image
pull: if-not-exists
image: plugins/docker
# privileged: true
settings:
mirror: https://docker.mirrors.ustc.edu.cn
storage_driver: vfs
cache_from: godd6366/drone-demo:latest
dockerfile: Dockerfile
repo: godd6366/drone-demo
tags:
- latest
- ${DRONE_BUILD_NUMBER}
username:
from_secret: DOCKER_NAME
password:
from_secret: DOCKER_PWD
- name: build-docker-compose
pull: if-not-exists
image: node
settings:
mirror: https://docker.mirrors.ustc.edu.cn
commands:
- node scripts/update.js --version ${DRONE_BUILD_NUMBER}
- name: scp-docker-compose
pull: if-not-exists
image: appleboy/drone-scp
settings:
host:
from_secret: SERVER_IP
username:
from_secret: SERVER_NAME
password:
from_secret: SERVER_PWD
port: 22
target: /volume1/MyFiles/DockerServers/drone-demo/${DRONE_BUILD_NUMBER}
source:
- docker-compose.yaml
- name: deploy-container
pull: if-not-exists
image: appleboy/drone-ssh
settings:
host:
from_secret: SERVER_IP
username:
from_secret: SERVER_NAME
password:
from_secret: SERVER_PWD
port: 22
script:
- export PATH=$HOME/bin:/usr/local/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:$PATH
# 关闭现有服务
- list=$(docker ps -a| grep my-demo-server | awk '{print $1}')
- test "$list" = "" && echo "none my-demo-server containers running" || docker rm $list -f
# 删除旧版本镜像
- imglist=$(docker images | grep drone-demo | awk '{print $3}')
- test "$imglist" = "" && echo "none drone-demo images" || docker rmi $imglist -f
# 启动新服务
- cd /volume1/MyFiles/DockerServers/drone-demo/${DRONE_BUILD_NUMBER}
- docker-compose up -d
- name: send
image: plugins/webhook
settings:
urls:
- https://xxxx.com/webhook # 换成自己的webhook服务器
when: # 无论成功失败都运行
status:
- failure
- success
trigger:
branch:
- main