-
Notifications
You must be signed in to change notification settings - Fork 0
/
.drone.yml
104 lines (94 loc) · 2.68 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
kind: pipeline
name: docker_stop
type: docker
clone:
disable: true
steps:
- name: stop docker
privileged: true
image: appleboy/drone-ssh:latest
settings:
host:
from_secret: ssh_ip
username:
from_secret: ssh_username
password:
from_secret: ssh_password
port:
from_secret: ssh_port
script:
- pwd
- echo =======暂停容器=======
- docker stop `docker ps -a | grep zero2prod | awk '{print $1}' `
- echo =======暂停旧容器和镜像=======
- docker rm -f `docker ps -a | grep springdemo | awk '{print $1}' `
- docker rmi `docker images | grep springdemo | awk '{print $3}' `
- exit 0
# - echo =======删除多余信息=======
# - docker system prune -f
# - docker system prune --volumes -f
---
kind: pipeline
name: fmt_audit-code
type: docker
steps:
- name: fmt code
pull: if-not-exists
image: rust_ci:latest
commands:
- cargo fmt -- --check
- name: audit-code
pull: if-not-exists
image: rust_ci:latest
commands:
# - cargo install cargo-audit
- cargo audit
- name: test_tarpaulin-code
privileged: true
pull: if-not-exists
image: rust_ci:latest
commands:
- cargo clippy
- cargo test
- cargo tarpaulin --ignore-tests
---
kind: pipeline
name: docker_start
type: docker
clone:
disable: true
steps:
- name: ssh commands
privileged: true
image: appleboy/drone-ssh:latest
settings:
host:
from_secret: ssh_ip
username:
from_secret: ssh_username
password:
from_secret: ssh_password
port:
from_secret: ssh_port
script:
- pwd
- echo =======暂停容器=======
- docker stop `docker ps -a | grep zero2prod | awk '{print $1}' `
- echo =======暂停旧容器和镜像=======
- docker rm -f `docker ps -a | grep springdemo | awk '{print $1}' `
- docker rmi `docker images | grep springdemo | awk '{print $3}' `
- echo =======删除多余信息=======
- docker system prune -f
- docker system prune --volumes -f
- echo =======清理完成开始建立新镜像=======
- cd /root/zero2prod_2023_2
- echo =======更新源码=======
- git pull
- echo =======覆盖率测试=======
- cargo tarpaulin --ignore-tests
- echo =======删除debug中的内容=======
- rm -rf /root/zero2prod_2023_2/target/debug/*
- echo =======建立容器=======
- docker build --tag zero2prod --file Dockerfile .
- echo =======运行容器=======
- docker run -d -p 8000:8000 zero2prod