-
Notifications
You must be signed in to change notification settings - Fork 18
/
.drone.yaml
212 lines (184 loc) · 4.18 KB
/
.drone.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
---
kind: pipeline
name: Pre-Flight
trigger:
event:
- push
steps:
- name: Restore .pre-commit Cache
image: meltwater/drone-cache:master-9a52545
settings:
archive_format: gzip
backend: filesystem
cache_key: pre_commit
mount:
- /drone/src/.pre-commit-cache
restore: true
volumes:
- name: cache
path: /tmp/cache
- name: Run All .pre-commit Hooks
image: python:3
environment:
PRE_COMMIT_HOME: /drone/src/.pre-commit-cache
commands:
- pip3 install pre-commit
- pre-commit install-hooks --config .pre-commit-config.yaml
- pre-commit run --all-files
- name: Rebuild .pre-commit Cache
image: meltwater/drone-cache:master-9a52545
settings:
archive_format: gzip
backend: filesystem
cache_key: pre_commit
mount:
- /drone/src/.pre-commit-cache
rebuild: true
volumes:
- name: cache
path: /tmp/cache
- name: Validate docker-compose.yml
image: wernight/docker-compose:1.24.0
commands:
- docker-compose config -q
volumes:
- name: cache
host:
path: /var/lib/cache
---
kind: pipeline
name: ESPHome
trigger:
event:
- push
depends_on:
- Pre-Flight
steps:
- name: "Config Check: Beta"
image: esphome/esphome:beta
pull: always
failure: ignore
commands:
- "for file in $(
find /drone/src/esphome
-type f
-name \"*.yaml\"
-not \ -name \"secrets.yaml\"
-not -name \".*.yaml\"
); do esphome config \"$file\"; done"
- name: "Config Check: Latest"
image: esphome/esphome:latest
pull: always
commands:
- "for file in $(
find /drone/src/esphome
-type f
-name \"*.yaml\"
-not \ -name \"secrets.yaml\"
-not -name \".*.yaml\"
); do esphome config \"$file\"; done"
---
kind: pipeline
name: Fail2Ban
trigger:
event:
- push
depends_on:
- Pre-Flight
steps:
- name: Config Check
image: alpine:3.10.1
commands:
- apk update && apk add --no-cache fail2ban
- ln -s ./fail2ban/settings /etc/fail2ban
- touch /var/log/messages
- mkdir -p /var/log/nginx
- touch /var/log/nginx/access.log
- touch /var/log/nginx/error.log
- fail2ban-client -t
---
kind: pipeline
name: Home Assistant
trigger:
event:
- push
depends_on:
- Pre-Flight
steps:
- name: "Config Check: Beta"
image: homeassistant/home-assistant:beta
pull: always
failure: ignore
commands:
- cd /usr/src/homeassistant
- "python -m homeassistant -c /drone/src/hass/settings \
--script check_config"
- name: "Config Check: RC"
image: homeassistant/home-assistant:rc
pull: always
failure: ignore
commands:
- cd /usr/src/homeassistant
- "python -m homeassistant -c /drone/src/hass/settings \
--script check_config"
- name: "Config Check: Latest"
image: homeassistant/home-assistant:latest
pull: always
commands:
- cd /usr/src/homeassistant
- "python -m homeassistant -c /drone/src/hass/settings \
--script check_config"
---
kind: pipeline
name: Build Notification
trigger:
event:
- push
status:
- success
- failure
depends_on:
- ESPHome
- Fail2Ban
- Home Assistant
steps:
- name: Send Notification
image: plugins/slack
settings:
webhook:
from_secret: slack_webhook
channel:
from_secret: slack_channel_name
template: >-
{{#success build.status}}
`{{repo.name}}/{{build.branch}}`: Build #{{build.number}}
successful ({{build.link}})
{{else}}
`{{repo.name}}/{{build.branch}}`: Build #{{build.number}}
failed ({{build.link}})
{{/success}}
when:
status:
- failure
- success
---
kind: pipeline
name: Deploy
trigger:
event:
- promote
target:
- production
steps:
- name: Deploy
image: appleboy/drone-ssh
settings:
host:
from_secret: deploy_ssh_host
username:
from_secret: deploy_ssh_username
port:
from_secret: deploy_ssh_port
key:
from_secret: deploy_ssh_key
command_timeout: 5m