-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaction.yaml
More file actions
367 lines (313 loc) · 13.5 KB
/
action.yaml
File metadata and controls
367 lines (313 loc) · 13.5 KB
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
name: 'Koyeb: build and deploy'
description: 'Build and deploy a GIT repository on Koyeb.'
branding:
icon: chevron-right
color: gray-dark
inputs:
app-name:
description: "The Koyeb application name to create"
required: false
service-name:
description: "Koyeb service name"
required: false
default: "${{ github.ref_name }}"
build-timeout:
description: "Maximum number of seconds to wait for the build"
required: false
# 15 minutes
default: "900"
healthy-timeout:
description: "Maximum number of seconds to wait for healthy status to be reached"
required: false
# 15 minutes
default: "900"
privileged:
description: "Whether to run the build in privileged mode"
required: false
default: "false"
# Docker deployment
docker:
description: "Docker image (only for docker deployments)"
required: false
default: ""
docker-entrypoint:
description: "Docker entrypoint (only for docker deployments)"
required: false
default: ""
docker-command:
description: "Docker CMD (only for docker deployments)"
required: false
default: ""
docker-private-registry-secret:
description: "Docker secret in case you are using a private registry (only for docker deployments)"
required: false
default: ""
# Git deployment
git-url:
description: "URL of the GIT repository to deploy"
required: false
default: "github.com/${{ github.repository }}"
git-workdir:
description: "Workdir, if the application to build is not in the root directory of the repository"
required: false
git-branch:
description: "GIT branch to deploy"
required: false
default: "${{ github.ref_name }}"
git-sha:
description: "Sha of the commit to deploy"
required: false
default: ""
git-builder:
description: "Type builder to use (buildpack or docker)"
required: false
default: "buildpack"
# Git deployment: buildpack builder options
git-build-command:
description: "Command to build the application (only for git deployments with the buildpack builder)"
required: false
default: ""
git-run-command:
description: "Command to run the application (only for git deployments with the buildpack builder)"
required: false
default: ""
# Git deployment: docker builder options
git-docker-command:
description: "Docker CMD (only for git deployments with the docker builder)"
required: false
default: ""
git-docker-dockerfile:
description: "Dockerfile path (only for git deployments with the docker builder)"
required: false
default: ""
git-docker-entrypoint:
description: "Docker entrypoint (only for git deployments with the docker builder)"
required: false
default: ""
git-docker-target:
description: "Dockerfile build target (only for git deployments with the docker builder)"
required: false
default: ""
# Service options
service-instance-type:
description: "Type of instance to use to run the service"
required: false
default: "nano"
service-regions:
description: "Comma separated list of region identifiers to specify where the service should be deployed"
required: false
default: "fra"
service-env:
description: "Comma separated list of <KEY>=<value> to specify the application environment"
required: false
default: ""
service-ports:
description: "Comma separated list of <KEY>=<value> to specify the ports to expose"
required: false
default: "80:http"
service-routes:
description: "Comma separated list of <path>:<port> to specify the routes to expose"
required: false
default: "/:80"
service-checks:
description: "Comma separated list of <port>:<protocol>:<path> to specify the service healthchecks"
required: false
service-checks-grace-period:
description: "Comma separated list of <healthcheck>=<seconds> to specify grace period values for healthchecks"
required: false
default: ""
service-proxy-ports:
description: "Comma separated list of <port>[:tcp] to specify proxy ports"
required: false
default: ""
service-volumes:
description: "Comma separated list of <volume>:<path> to attach service volumes"
required: false
default: ""
service-scale:
description: "Set both min-scale and max-scale values"
required: false
default: ""
service-min-scale:
description: "Set minimum number of instances"
required: false
default: ""
service-max-scale:
description: "Set maximum number of instances"
required: false
default: ""
service-autoscaling-average-cpu:
description: "Target CPU usage percentage for autoscaling"
required: false
default: ""
service-autoscaling-average-mem:
description: "Target memory usage percentage for autoscaling"
required: false
default: ""
service-autoscaling-concurrent-requests:
description: "Target concurrent requests for autoscaling"
required: false
default: ""
service-autoscaling-requests-per-second:
description: "Target requests per second for autoscaling"
required: false
default: ""
service-autoscaling-requests-response-time:
description: "Target p95 response time in milliseconds for autoscaling"
required: false
default: ""
service-deployment-strategy:
description: "Deployment strategy (rolling, blue-green, immediate)"
required: false
default: ""
service-light-sleep-delay:
description: "Delay before entering light sleep (for example 1m, 5m, 1h, 0)"
required: false
default: ""
service-deep-sleep-delay:
description: "Delay before entering deep sleep (for example 5m, 30m, 1h, 0)"
required: false
default: ""
service-delete-after-delay:
description: "Automatically delete service after this duration (for example 1h, 24h, 0)"
required: false
default: ""
service-delete-after-inactivity-delay:
description: "Automatically delete service after inactivity for this duration (for example 1h, 24h, 0)"
required: false
default: ""
service-type:
description: "Service type (\"web\", \"worker\", or \"sandbox\")"
required: false
default: "web"
skip-cache:
description: "Whether to skip the cache when building the application"
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Slugify application name
shell: sh
run: |
if [ -z "${{ inputs.app-name }}" ]; then
# Remove the owner from the repository
APP_SLUG=$(echo '${{ github.repository }}/${{ github.ref_name }}' | cut -d '/' -f 2-)
else
APP_SLUG="${{ inputs.app-name }}"
fi
# sed: to replace non alphanum chars with -
# tail: limit to the last 23 chars (maximum Koyeb application name)
# sed: if the leading char is a dash, remove it
echo "APP_SLUG=$(echo $APP_SLUG | sed 's/[^a-z0-9]/-/g' | tail -c 24 | sed 's/^-//g')" | tee $GITHUB_ENV
- name: Slugify service name
shell: sh
run: |
# sed: to replace non alphanum chars with -
echo "SERVICE_SLUG=$(echo ${{ inputs.service-name }} | sed 's/[^a-z0-9]/-/g')" | tee $GITHUB_ENV
- name: Create Koyeb application
shell: sh
run: |
${{ github.action_path }}/scripts/app-create.py \
--app-name "${{ env.APP_SLUG }}"
- name: Create Koyeb service
shell: sh
run: |
if [ -n "${{ inputs.docker }}" ]; then
${{ github.action_path }}/scripts/service-upsert.py \
--app-name "${{ env.APP_SLUG }}" \
--service-type "${{ inputs.service-type }}" \
--service-name "${{ env.SERVICE_SLUG }}" \
--docker "${{ inputs.docker }}" \
--docker-entrypoint "${{ inputs.docker-entrypoint }}" \
--docker-command "${{ inputs.docker-command }}" \
--docker-private-registry-secret "${{ inputs.docker-private-registry-secret }}" \
--service-instance-type "${{ inputs.service-instance-type }}" \
--service-regions "${{ inputs.service-regions }}" \
--service-env "${{ inputs.service-env }}" \
--service-ports "${{ inputs.service-ports }}" \
--service-routes "${{ inputs.service-routes }}" \
--service-checks "${{ inputs.service-checks }}" \
--service-checks-grace-period "${{ inputs.service-checks-grace-period }}" \
--service-proxy-ports "${{ inputs.service-proxy-ports }}" \
--service-volumes "${{ inputs.service-volumes }}" \
--service-scale "${{ inputs.service-scale }}" \
--service-min-scale "${{ inputs.service-min-scale }}" \
--service-max-scale "${{ inputs.service-max-scale }}" \
--service-autoscaling-average-cpu "${{ inputs.service-autoscaling-average-cpu }}" \
--service-autoscaling-average-mem "${{ inputs.service-autoscaling-average-mem }}" \
--service-autoscaling-concurrent-requests "${{ inputs.service-autoscaling-concurrent-requests }}" \
--service-autoscaling-requests-per-second "${{ inputs.service-autoscaling-requests-per-second }}" \
--service-autoscaling-requests-response-time "${{ inputs.service-autoscaling-requests-response-time }}" \
--service-deployment-strategy "${{ inputs.service-deployment-strategy }}" \
--service-light-sleep-delay "${{ inputs.service-light-sleep-delay }}" \
--service-deep-sleep-delay "${{ inputs.service-deep-sleep-delay }}" \
--service-delete-after-delay "${{ inputs.service-delete-after-delay }}" \
--service-delete-after-inactivity-delay "${{ inputs.service-delete-after-inactivity-delay }}" \
--privileged "${{ inputs.privileged }}" \
--skip-cache "${{ inputs.skip-cache }}"
else
${{ github.action_path }}/scripts/service-upsert.py \
--app-name "${{ env.APP_SLUG }}" \
--service-type "${{ inputs.service-type }}" \
--service-name "${{ env.SERVICE_SLUG }}" \
--git-url "${{ inputs.git-url }}" \
--git-workdir "${{ inputs.git-workdir }}" \
--git-branch "${{ inputs.git-branch }}" \
--git-sha "${{ inputs.git-sha }}" \
--git-builder "${{ inputs.git-builder }}" \
--git-build-command "${{ inputs.git-build-command }}" \
--git-run-command "${{ inputs.git-run-command }}" \
--git-docker-command "${{ inputs.git-docker-command }}" \
--git-docker-dockerfile "${{ inputs.git-docker-dockerfile }}" \
--git-docker-entrypoint "${{ inputs.git-docker-entrypoint }}" \
--git-docker-target "${{ inputs.git-docker-target }}" \
--service-instance-type "${{ inputs.service-instance-type }}" \
--service-regions "${{ inputs.service-regions }}" \
--service-env "${{ inputs.service-env }}" \
--service-ports "${{ inputs.service-ports }}" \
--service-routes "${{ inputs.service-routes }}" \
--service-checks "${{ inputs.service-checks }}" \
--service-checks-grace-period "${{ inputs.service-checks-grace-period }}" \
--service-proxy-ports "${{ inputs.service-proxy-ports }}" \
--service-volumes "${{ inputs.service-volumes }}" \
--service-scale "${{ inputs.service-scale }}" \
--service-min-scale "${{ inputs.service-min-scale }}" \
--service-max-scale "${{ inputs.service-max-scale }}" \
--service-autoscaling-average-cpu "${{ inputs.service-autoscaling-average-cpu }}" \
--service-autoscaling-average-mem "${{ inputs.service-autoscaling-average-mem }}" \
--service-autoscaling-concurrent-requests "${{ inputs.service-autoscaling-concurrent-requests }}" \
--service-autoscaling-requests-per-second "${{ inputs.service-autoscaling-requests-per-second }}" \
--service-autoscaling-requests-response-time "${{ inputs.service-autoscaling-requests-response-time }}" \
--service-deployment-strategy "${{ inputs.service-deployment-strategy }}" \
--service-light-sleep-delay "${{ inputs.service-light-sleep-delay }}" \
--service-deep-sleep-delay "${{ inputs.service-deep-sleep-delay }}" \
--service-delete-after-delay "${{ inputs.service-delete-after-delay }}" \
--service-delete-after-inactivity-delay "${{ inputs.service-delete-after-inactivity-delay }}" \
--privileged "${{ inputs.privileged }}" \
--skip-cache "${{ inputs.skip-cache }}"
fi
- id: get-deployment
name: Get last deployment of the Koyeb service
shell: sh
run: |
${{ github.action_path }}/scripts/deployment-get-last-id.py \
--app-name "${{ env.APP_SLUG }}" \
--service-name "${{ env.SERVICE_SLUG }}" | tee $GITHUB_OUTPUT
- name: Show build logs
shell: sh
run: |
${{ github.action_path }}/scripts/deployment-show-build-logs.py \
--deployment-id "${{ steps.get-deployment.outputs.deployment-id }}" \
--timeout "${{ inputs.build-timeout }}"
- name: Poll deployment status
shell: sh
run: |
${{ github.action_path }}/scripts/deployment-wait-healthy.py \
--deployment-id "${{ steps.get-deployment.outputs.deployment-id }}" \
--timeout "${{ inputs.healthy-timeout }}"
- name: Show app domain
shell: sh
run: |
${{ github.action_path }}/scripts/app-show-domain.py \
--app-name "${{ env.APP_SLUG }}"