-
Notifications
You must be signed in to change notification settings - Fork 4
/
.drone.star
246 lines (236 loc) · 7.68 KB
/
.drone.star
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
def main(ctx):
# Config
environment = "main-page"
# Version shown as latest in generated documentations
# It's fine that this is out of date in version branches, usually just needs
# adjustment in master/deployment_branch when a new version is added to site.yml
latest_version = "master"
default_branch = "master"
# Current version branch (used to determine when changes are supposed to be pushed)
# pushes to base_branch will trigger a build in deployment_branch but pushing
# to fix-typo branch won't
base_branch = latest_version
# Version branches never deploy themselves, but instead trigger a deployment in deployment_branch
# This must not be changed in version branches
deployment_branch = default_branch
pdf_branch = default_branch
# Environment variables needed to generate the search index are only provided in the docs repo in .drone.star.
# Also see the documentation for more details.
return [
checkStarlark(),
build(ctx, environment, latest_version, deployment_branch, base_branch, pdf_branch),
trigger(ctx, environment, latest_version, deployment_branch, base_branch, pdf_branch),
]
def checkStarlark():
return {
"kind": "pipeline",
"type": "docker",
"name": "check-starlark",
"steps": [
{
"name": "format-check-starlark",
"image": "owncloudci/bazel-buildifier",
"pull": "always",
"commands": [
"buildifier --mode=check .drone.star",
],
},
{
"name": "show-diff",
"image": "owncloudci/bazel-buildifier",
"pull": "always",
"commands": [
"buildifier --mode=fix .drone.star",
"git diff",
],
"when": {
"status": [
"failure",
],
},
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/pull/**",
],
},
}
def build(ctx, environment, latest_version, deployment_branch, base_branch, pdf_branch):
return {
"kind": "pipeline",
"type": "docker",
"name": "documentation",
"platform": {
"os": "linux",
"arch": "amd64",
},
"steps": [
{
"name": "cache-restore",
"pull": "always",
"image": "plugins/s3-cache:1",
"settings": {
"endpoint": from_secret("cache_s3_server"),
"access_key": from_secret("cache_s3_access_key"),
"secret_key": from_secret("cache_s3_secret_key"),
"restore": "true",
},
},
{
"name": "docs-deps",
"pull": "always",
"image": "owncloudci/nodejs:18",
"commands": [
"yarn install",
],
},
{
"name": "docs-build",
"pull": "always",
"image": "owncloudci/nodejs:18",
"commands": [
"yarn antora",
],
},
{
"name": "cache-rebuild",
"pull": "always",
"image": "plugins/s3-cache:1",
"settings": {
"endpoint": from_secret("cache_s3_server"),
"access_key": from_secret("cache_s3_access_key"),
"secret_key": from_secret("cache_s3_secret_key"),
"rebuild": "true",
"mount": [
"node_modules",
],
},
"when": {
"event": [
"push",
"cron",
],
"branch": [
deployment_branch,
base_branch,
],
},
},
{
"name": "cache-flush",
"pull": "always",
"image": "plugins/s3-cache:1",
"settings": {
"endpoint": from_secret("cache_s3_server"),
"access_key": from_secret("cache_s3_access_key"),
"secret_key": from_secret("cache_s3_secret_key"),
"flush": "true",
"flush_age": "14",
},
"when": {
"event": [
"push",
"cron",
],
},
},
# we keep uploading pdf for future reenabling
#{
# "name": "upload-pdf",
# "pull": "always",
# "image": "plugins/s3-sync",
# "settings": {
# "bucket": "uploads",
# "endpoint": from_secret("docs_s3_server"),
# "access_key": from_secret("docs_s3_access_key"),
# "secret_key": from_secret("docs_s3_secret_key"),
# "path_style": "true",
# "source": "pdf_web/",
# "target": "/pdf/%s" % environment,
# },
# "when": {
# "event": [
# "push",
# "cron",
# ],
# "branch": [
# pdf_branch,
# ],
# },
#},
{
"name": "notify",
"pull": "if-not-exists",
"image": "plugins/slack",
"settings": {
"webhook": from_secret("rocketchat_talk_webhook"),
"channel": "builds",
},
"when": {
"event": [
"push",
"cron",
],
"status": [
"failure",
],
},
},
],
"depends_on": [
"check-starlark",
],
"trigger": {
"ref": {
"include": [
"refs/heads/%s" % deployment_branch,
"refs/heads/%s" % pdf_branch,
"refs/tags/**",
"refs/pull/**",
],
},
},
}
def trigger(ctx, environment, latest_version, deployment_branch, base_branch, pdf_branch):
return {
"kind": "pipeline",
"type": "docker",
"name": "trigger",
"platform": {
"os": "linux",
"arch": "amd64",
},
"clone": {
"disable": True,
},
"steps": [
{
"name": "trigger-docs",
"pull": "always",
"image": "plugins/downstream",
"settings": {
"server": "https://drone.owncloud.com",
"token": from_secret("drone_token"),
"fork": "true",
"repositories": [
"owncloud/docs@master",
],
},
},
],
"depends_on": [
"documentation",
],
"trigger": {
"ref": [
"refs/heads/%s" % deployment_branch,
"refs/heads/%s" % base_branch,
],
},
}
def from_secret(name):
return {
"from_secret": name,
}