-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.drone.yml
99 lines (92 loc) · 2.48 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
kind: pipeline
type: docker
name: netdevops cicd proof of concept
steps:
- name: preping build
image: vireakouk/netdevops-drone-nornir-scrapli:latest
commands:
- echo 'starting build'
- git --version
- python --version
- pip list
- git checkout ${DRONE_BRANCH}
- name: pre-deployment test
image: vireakouk/netdevops-drone-nornir-scrapli:latest
commands:
- pip install pybatfish rich
- python test.py
when:
branch:
- dev
- name: dry run
image: vireakouk/netdevops-drone-nornir-scrapli:latest
environment:
NORNIR_USER:
from_secret: NORNIR_USER
NORNIR_SECRET:
from_secret: NORNIR_SECRET
commands:
- git fetch
- python update_config.py --dry_run
when:
branch:
- dev
- name: merge to main
image: vireakouk/netdevops-drone-nornir-scrapli:latest
commands:
- git checkout main
- git branch -u origin/main
- git remote -v
- git merge dev
- git push --all
when:
branch:
- dev
- name: deploy to production
image: vireakouk/netdevops-drone-nornir-scrapli:latest
environment:
NORNIR_USER:
from_secret: NORNIR_USER
NORNIR_SECRET:
from_secret: NORNIR_SECRET
commands:
- python update_config.py
when:
branch:
- main
- name: post-deployment test
image: vireakouk/netdevops-drone-nornir-scrapli:latest
commands:
- pip install pybatfish rich
- python test.py
when:
branch:
- main
- name: send telegram notification
image: appleboy/drone-telegram
settings:
token:
from_secret: TELEGRAM_TOKEN
to:
from_secret: TELEGRAM_USER_ID
message: >
{{#success build.status}}
✅ Build #{{ build.number }} of `{{ repo.name }}` succeeded.
📝 Committed by {{ commit.author }} on `{{ commit.branch }}`:
```
{{ commit.message }}
```
🌐 Commit Link: {{ commit.link }}
🌐 Build Link: {{ build.link }}
{{else}}
❌ Build #{{ build.number }} of `{{ repo.name }}` failed.
📝 Committed by {{ commit.author }} on `{{ commit.branch }}`:
```
{{ commit.message }}
```
🌐 Commit Link: {{ commit.link }}
🌐 Build Link: {{ build.link }}
{{/success}}
when:
status: [ success, failure ]
branch: [ main, dev ]