This repository has been archived by the owner on Nov 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
361 lines (285 loc) · 11 KB
/
push_container.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
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
---
name: mmmm_cookies-push-container
# Workflow Secrets:
# SLACK_WEBHOOK (Required, for slack notifications...)
on:
push:
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:
env:
PROJECT_NAME: "mmmm_cookies"
USERNAME: "niall-byrne"
VERBOSE_NOTIFICATIONS: 0
jobs:
_start_notification:
runs-on: ubuntu-latest
steps:
- name: Start -- Checkout Repository
uses: actions/checkout@v3
- name: Start -- Setup Environment
run: |
source ./.github/scripts/setup.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Start -- Report Job Status on Success
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: workflow has started!"
- name: Start -- Report Job Status on Failure
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: error reporting job status!"
_success_notification:
needs: [create_release]
runs-on: ubuntu-latest
steps:
- name: Success -- Checkout Repository
uses: actions/checkout@v3
- name: Success -- Setup Environment
run: |
source .github/scripts/setup.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Success -- Report Job Status on Success
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: all checks were successful!"
- name: Success -- Report Job Status on Failure
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: error reporting job status!"
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
include:
- python-version: 3.7
steps:
- name: Build -- Checkout
uses: actions/checkout@v3
- name: Build -- Setup Environment
run: |
source .github/scripts/setup.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
PYTHON_VERSION: ${{ matrix.python-version }}
- name: Build -- Create Docker Mounted Content
run: |
echo | ssh-keygen
touch ${HOME}/.gitconfig
touch ${HOME}/.gitconfig_global
- name: Build -- Build Container
run: |
source .github/scripts/build_container.sh
- name: Build -- Run TOML Linter
run: |
docker-compose exec -T "${PROJECT_NAME}" tomll /app/pyproject.toml
- name: Build -- Run Linter
run: |
docker-compose exec -T "${PROJECT_NAME}" dev lint
- name: Build -- Run Sec Test
run: |
docker-compose exec -T "${PROJECT_NAME}" dev sectest
- name: Build -- Run Unit Tests
run: |
docker-compose exec -T "${PROJECT_NAME}" dev coverage
- name: Build -- Run Release Validation
run: |
docker-compose exec -T "${PROJECT_NAME}" ./scripts/utilities/check_release.sh
- name: Build -- Report Job Status (Success)
if: env.VERBOSE_NOTIFICATIONS == '1'
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: build for Python ${PYTHON_VERSION} was successful"
- name: Build -- Report Job Status (Failure)
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: build for Python ${PYTHON_VERSION} failed!"
create_release:
needs: [_start_notification, build, dockerfile_test, documentation_test, security_test, shellcheck_test, workflow_lint_test]
runs-on: ubuntu-latest
steps:
- name: Create Release -- Branch Filter
id: branch_filter
run: |
MATCH="FALSE"
[[ "${{ github.event.ref }}" =~ /tags/v\.* ]] && MATCH="TRUE"
echo "MATCH=${MATCH}" >> $GITHUB_OUTPUT
- name: Create Release -- Checkout
if: steps.branch_filter.outputs.match == 'TRUE'
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create Release -- Setup Environment
if: steps.branch_filter.outputs.match == 'TRUE'
run: |
source .github/scripts/setup.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Create Release -- Generate Changelog
if: steps.branch_filter.outputs.match == 'TRUE'
run: |
source .github/scripts/changelog.sh
- name: Create Release -- Generate Github Release Draft
if: steps.branch_filter.outputs.match == 'TRUE'
id: create_release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const result = await github.rest.repos.createRelease({
body: process.env.CHANGE_LOG_CONTENT,
draft: true,
name: "Release " + process.env.BRANCH_OR_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.BRANCH_OR_TAG,
});
return result.upload_url
} catch (error) {
core.setFailed(error.message);
}
- name: Create Release -- Report Success
if: steps.branch_filter.outputs.match == 'TRUE'
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: automated release has been created:\nhttps://github.com/${USERNAME}/${PROJECT_NAME}/releases"
- name: Create Release -- Report Failure
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: automated release generation failed!"
dockerfile_test:
runs-on: ubuntu-latest
steps:
- name: Dockerfile Test -- Checkout Repository
uses: actions/checkout@v3
- name: Dockerfile Test -- Setup Environment
run: |
source .github/scripts/setup.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Dockerfile Test -- Documentation Validation
uses: hadolint/hadolint-action@v3.0.0
with:
dockerfile: assets/Dockerfile
failure-threshold: error
config: ./.hadolint.yml
- name: Dockerfile Test -- Build the container image
run: docker build . --file assets/Dockerfile --tag test:latest --target development
- name: Dockerfile Test -- Scan image
id: scan
uses: anchore/scan-action@v3
with:
image: "test:latest"
fail-build: false
acs-report-enable: true
severity-cutoff: critical
- name: Dockerfile Test -- Upload Anchore scan SARIF report
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
- name: Dockerfile Test -- Report Success
if: env.VERBOSE_NOTIFICATIONS == '1'
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: dockerfile linting was successful!"
- name: Dockerfile Test -- Report Failure
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: dockerfile linting failed!"
documentation_test:
runs-on: ubuntu-latest
steps:
- name: Documentation Test -- Checkout Repository
uses: actions/checkout@v3
- name: Documentation Test -- Setup Environment
run: |
source .github/scripts/setup.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Documentation Test -- Documentation Validation
uses: gaurav-nelson/github-action-markdown-link-check@1.0.13
with:
config-file: './.github/config/markdown.link.check.json'
use-quiet-mode: 'no'
use-verbose-mode: 'yes'
- name: Documentation Test -- Report Success
if: env.VERBOSE_NOTIFICATIONS == '1'
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: documentation checks were successful!"
- name: Documentation Test -- Report Failure
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: documentation checks failed!"
security_test:
runs-on: ubuntu-latest
steps:
- name: Security Test -- Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Security Test -- Setup Environment
run: |
source ./.github/scripts/setup.sh
source ./.github/scripts/pushed_commit_range.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Security Test -- Run Trufflehog
uses: trufflesecurity/trufflehog@v3.20.0
with:
path: .
base: ${{ env.PUSHED_COMMIT_RANGE }}
head: ${{ env.BRANCH_OR_TAG }}
- name: Security Test -- Report Success
if: env.VERBOSE_NOTIFICATIONS == '1'
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: security checks were successful!"
- name: Security Test -- Report Failure
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: security checks failed!"
shellcheck_test:
runs-on: ubuntu-latest
steps:
- name: Shellcheck -- Checkout Repository
uses: actions/checkout@v3
- name: Shellcheck -- Setup Environment
run: |
source .github/scripts/setup.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Shellcheck -- Check Scripts
run: |
source ./.github/scripts/lint_shellcheck.sh
- name: Shellcheck -- Report Job Status on Success
if: env.VERBOSE_NOTIFICATIONS == '1'
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: shellcheck checks were successful!"
- name: Shellcheck -- Report Job Status on Failure
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: shellcheck checks failed!"
workflow_lint_test:
runs-on: ubuntu-latest
steps:
- name: Workflow Lint -- Checkout Repository
uses: actions/checkout@v3
- name: Workflow Lint -- Setup Environment
run: |
source ./.github/scripts/setup.sh
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Workflow Lint -- Run Linter
uses: ibiqlik/action-yamllint@v3
with:
format: standard
file_or_dir: ./.github/workflows
config_file: .yamllint.yml
- name: Workflow Lint -- Report Job Status on Success
if: env.VERBOSE_NOTIFICATIONS == '1'
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: workflow linting was successful!"
- name: Workflow Lint -- Report Job Status on Failure
if: failure()
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":x: workflow linting has failed!"