-
Notifications
You must be signed in to change notification settings - Fork 0
325 lines (305 loc) · 9.99 KB
/
Copy pathdeploy-docs.yaml
File metadata and controls
325 lines (305 loc) · 9.99 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
# This workflow will build and deploy documentation on the aws cloudfront.
name: Build and Deploy Documentation (AWS Cloudfront)
on:
workflow_call:
inputs:
#
# Common settings
#
app-name:
description: |
Application name in human-readable form.
As it is supposed to be shown in messages
type: string
required: false
default: ${{ github.repository }}
app-name-slug:
description: |
Application name slug (part of release file name)
type: string
required: true
#
# Checkout settings
#
git-crypt-unlock:
description: |
Perform `git ctypt unlock` after each fresh repository checkout
NOTE: don't forget to set the following secrets:
- GIT_CRYPT_GPG_KEY
- GIT_CRYPT_KEY_PASSWORD
type: boolean
required: false
default: false
checkout-submodules:
description: |
'Submodules' mode for 'actions/checkout' action
'', 'false' - disable submodules support
'true' - checkout submodules
'recursive' - checkout submodules recursive
type: string
required: false
default: ''
#
# Environment settings
#
env:
description: |
custom environment variables to set for all jobs in workflow
as JSON-encoded map:
{ "MY_VAR_1": "awesome value",
"VARIABLE_2": "not so awesome :)" }
This input's envs are merged with secrets.env
This input's envs have lower priority compared than secrets.env
type: string
required: false
default: '{}'
#
# Build settings
#
plantuml-version:
description: |
The version of Plantuml to install.
(Generate diagrams from textual description )
type: string
required: false
default: '1.2022.0'
python-version:
description: |
The version of Python to install
type: string
required: false
default: '3.10'
#
# Archive distribution control
#
dist-archive-path:
description: The name of a distribution folder for generate docs.
type: string
required: false
default: 'site'
dist-artifact-retention:
description: |
Time in days to keep build artifacts before removing them
type: number
required: false
default: 7
#
# AWS settings
#
aws-iam-role-to-assume:
description: |
The ARN of a IAM role to assume and configure the Actions environment with
assumed role credentials.
type: string
required: true
aws-region:
description: |
The AWS region
type: string
required: true
default: 'us-east-1'
aws-cloudfront-distribution-id:
description: |
The ID of an AWS Cloudfront distribution
type: string
required: true
aws-cloudfront-s3-bucket-name:
description: |
The name of an aws s3 bucket to sync static files
type: string
required: true
aws-cloudfront-cache-invalidation:
description: |
Invalidate the cache on the AWS Cloudfornt for a given distribution
type: string
required: false
default: 'true'
#
# Notifications
#
notify-telegram:
description: |
Enable Telegram notifications
required: false
type: boolean
default: true
notify-build:
description: |
Enable notifications about build status (build ready/failed)
Possible values are:
- 'true' - send all notifications about build status (both success and failed)
- 'failure-only' - send notification about failed builds, don't notify on success
- 'success-only' - send notification about success builds, don't notify on failures
- 'false' - don't send notifications about build results at all.
required: false
type: string
default: 'true'
notify-deployment:
description: |
Enable notifications about deployment status (deployment ready/failed)
Possible values are:
- 'true' - send all notifications about deployment status (both success and failed)
- 'false' - don't send notifications about deployment results at all.
required: false
type: string
default: 'true'
secrets:
env:
description: |
custom environment variables to set for all jobs in workflow
as JSON-encoded map:
{ "MY_VAR_1": "awesome value",
"VARIABLE_2": "not so awesome :)" }
This input's envs are merged with inputs.env
This input's envs have HIGHER priority compared than inputs.env
required: false
TELEGRAM_NOTIFICATION_TARGET:
description: |
ID of Telegram Channel or User to notify on build results.
required: false
TELEGRAM_API_TOKEN:
description: |
Telegram Bot API authorization token
required: false
GIT_CRYPT_GPG_KEY:
description: |
base64-encoded GPG key pair
(see actions/git/crypt inputs description)
required: false
GIT_CRYPT_KEY_PASSWORD:
description: |
Password for GPG key
required: false
jobs:
init:
name: Init
runs-on: ubuntu-latest
steps:
- id: context
uses: milaboratory/github-ci/actions/context@v4
build:
name: :build
runs-on: ubuntu-latest
needs:
- init
steps:
- uses: milaboratory/github-ci/actions/env@v4
with:
inputs: ${{ inputs.env }}
secrets: ${{ secrets.env }}
- uses: actions/checkout@v4
with:
submodules: ${{ inputs.checkout-submodules }}
- uses: milaboratory/github-ci/actions/git/crypt@v4
if: inputs.git-crypt-unlock
with:
gpg-key: ${{ secrets.GIT_CRYPT_GPG_KEY }}
gpg-key-password: ${{ secrets.GIT_CRYPT_KEY_PASSWORD }}
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: 'pip'
- uses: milaboratory/github-ci/actions/shell@v4
with:
dump-stdout: false
run: |
sudo apt-get install -y graphviz
- uses: milaboratory/github-ci/actions/shell@v4
with:
dump-stdout: false
run: |
sudo curl -s -L "https://github.com/plantuml/plantuml/releases/download/v${{ inputs.plantuml-version }}/plantuml-${{ inputs.plantuml-version }}.jar" --output /opt/plantuml.jar
- uses: milaboratory/github-ci/actions/shell@v4
with:
dump-stdout: false
run: |
echo '#!/bin/bash' > /usr/local/bin/plantuml
echo 'java $PLANTUML_JAVAOPTS -jar /opt/plantuml.jar ${@}' >> /usr/local/bin/plantuml
chmod +x /usr/local/bin/plantuml
- uses: milaboratory/github-ci/actions/shell@v4
with:
dump-stdout: false
run: |
pip install pip==24.0 && pip install -r requirements.txt
- uses: milaboratory/github-ci/actions/shell@v4
with:
dump-stdout: false
run: |
mkdocs build
- id: artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.app-name-slug }}
path: ${{ inputs.dist-archive-path }}
retention-days: ${{ inputs.dist-artifact-retention }}
notify-build:
name: Notify build
runs-on: ubuntu-latest
if: always()
&& inputs.notify-telegram
&& inputs.notify-build != 'false'
&& needs.build.result != 'cancelled'
needs:
- build
steps:
- id: search-tags
if: always()
uses: milaboratory/github-ci/actions/strings/json-list@v4
with:
input: |
build
- uses: milaboratory/github-ci/blocks/notify/build@v4
with:
telegram-target: ${{ secrets.TELEGRAM_NOTIFICATION_TARGET }}
telegram-token: ${{ secrets.TELEGRAM_API_TOKEN }}
build-status: |
${{ needs.build.result }}
product-name: ${{ inputs.app-name }}
search-tags: ${{ steps.search-tags.outputs.result }}
deployment:
name: :deployment
runs-on: ubuntu-latest
needs:
- init
- build
permissions:
id-token: write
contents: read
steps:
- id: context
uses: milaboratory/github-ci/actions/context@v4
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.app-name-slug }}
path: ${{ inputs.app-name-slug }}
- uses: milaboratory/github-ci/actions/aws/cloudfront@v4
with:
aws-iam-role-to-assume: ${{ inputs.aws-iam-role-to-assume }}
aws-region: ${{ inputs.aws-region }}
aws-cloudfront-distribution-id: ${{ inputs.aws-cloudfront-distribution-id }}
aws-cloudfront-s3-bucket-name: ${{ inputs.aws-cloudfront-s3-bucket-name }}
aws-cloudfront-cache-invalidation: ${{ inputs.aws-cloudfront-cache-invalidation }}
dist-assets: ${{ inputs.app-name-slug }}/
notify-deployment:
name: notify deployment
runs-on: ubuntu-latest
if: always()
&& inputs.notify-telegram
&& inputs.notify-deployment != 'false'
needs:
- deployment
steps:
- id: search-tags
if: always()
uses: milaboratory/github-ci/actions/strings/json-list@v4
with:
input: |
deployment
- uses: milaboratory/github-ci/blocks/notify/deployment@v4
with:
telegram-target: ${{ secrets.TELEGRAM_NOTIFICATION_TARGET }}
telegram-token: ${{ secrets.TELEGRAM_API_TOKEN }}
job-status: |
${{ needs.deployment.result }}
product-name: ${{ inputs.app-name }}
search-tags: ${{ steps.search-tags.outputs.result }}