-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (93 loc) · 2.67 KB
/
test-build-and-push-code.yaml
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
name: Test, build and push code to docker registry
on:
push:
branches:
- 'main'
paths:
- 'Dockerfile'
- '.github/workflows/build-and-push-docker-image.yaml'
- '*.py'
- 'yaml-templates/*'
schedule:
- cron: '0 8 * * *'
workflow_call:
jobs:
test-python:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: flake8 Lint
uses: py-actions/flake8@v2
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Unittest
run: |
python -m unittest discover
python -m unittest -v
build-and-push-image:
runs-on: ubuntu-latest
needs: test-python
permissions:
contents: read
packages: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Docker login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/dfe-digital/automated-threat-models
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
test-action:
runs-on: ubuntu-latest
needs: build-and-push-image
permissions:
contents: read
packages: read
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Test threagile help
id: threagile-test-optional-args
uses: pritchyspritch/run-threagile-action@v2
with:
optional_args: '--help'
- name: Test threagile with real model
id: threagile
uses: pritchyspritch/run-threagile-action@v2
with:
model_file: 'example-models/threagile-SSPHP-model.yaml'
output_dir: 'test/location'
# will fail as Azure data ingestion hasn't been automated yet
- name: Test threagile dfe automation
id: dfe-threagile
uses: pritchyspritch/run-threagile-action@v2
with:
dfe_threagile: 'true'
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: threat-model-output
path: test/location