This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
forked from XGovFormBuilder/digital-form-builder
-
Notifications
You must be signed in to change notification settings - Fork 1
238 lines (216 loc) · 8.12 KB
/
copilot_deploy.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
name: Deploy to AWS
run-name: ${{ github.event_name == 'workflow_dispatch' && format('Deploy to {0}', github.event.inputs.environment) || (github.ref == 'refs/heads/main' && 'Deploy to Test-UAT-Prod' || 'Build & Unit Test') }}
permissions:
packages: write
contents: write
on:
push:
paths-ignore:
[
"**/README.md",
".github/workflows/increment-version.yml",
"version",
"python/**",
]
workflow_dispatch:
inputs:
environment:
description: Deploy to which environnment
type: choice
required: true
options:
- dev
- test
- uat
- prod
run_performance_tests:
required: false
default: false
type: boolean
description: Run performance tests
run_e2e_tests_assessment:
required: false
default: false
type: boolean
description: Run e2e tests (assessment)
run_e2e_tests_application:
required: false
default: true
type: boolean
description: Run e2e tests (application)
env:
DOCKER_REGISTRY: ghcr.io
IMAGE_NAME: "funding-service-design-form-runner"
IMAGE_REPO_PATH: "ghcr.io/${{github.repository_owner}}"
jobs:
setup:
uses: communitiesuk/funding-service-design-workflows/.github/workflows/determine-jobs.yml@main
with:
environment: ${{ inputs.environment }}
docker-build:
runs-on: ubuntu-latest
needs: [setup]
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: "Set version in env"
id: set-version
run: |
source version
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{env.IMAGE_REPO_PATH}}/${{env.IMAGE_NAME}}
tags: |
type=sha,format=long
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=${{env.VERSION}},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=ref,event=branch
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create .env for runner workspace
run: |
touch ./runner/.env
echo LAST_TAG_GH=runner >> ./runner/.env
echo LAST_COMMIT_GH=runner >> ./runner/.env
cat ./runner/.env
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
context: .
tags: ${{ steps.metadata.outputs.tags}}
labels: ${{ steps.metadata.outputs.labels }}
push: true
file: ./fsd_config/Dockerfile
build-args: |
LAST_TAG='${{env.VERSION}}'
LAST_COMMIT='${{ github.sha }}'
dev_deploy:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
needs: [docker-build, setup]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'dev') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') ) }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main
secrets:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
with:
environment: dev
app_name: "form-runner"
version: sha-${{ github.sha }}
post_dev_deploy_tests:
needs: [dev_deploy]
secrets:
FSD_GH_APP_ID: ${{ secrets.FSD_GH_APP_ID }}
FSD_GH_APP_KEY: ${{ secrets.FSD_GH_APP_KEY }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main
with:
run_performance_tests: ${{ inputs.run_performance_tests || true }}
run_e2e_tests_assessment: ${{ inputs.run_e2e_tests_assessment || false }}
run_e2e_tests_application: ${{ inputs.run_e2e_tests_application || false }}
run_static_security_python: false
run_zap_scan: true
app_name: forms
environment: dev
test_deploy:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
needs: [setup, docker-build, dev_deploy, post_dev_deploy_tests]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'test') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') ) }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main
secrets:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
with:
environment: "test"
app_name: "form-runner"
version: sha-${{ github.sha }}
post_test_deploy_tests:
needs: [setup, docker-build, dev_deploy, post_dev_deploy_tests, test_deploy]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'test') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') ) }}
secrets:
FSD_GH_APP_ID: ${{ secrets.FSD_GH_APP_ID }}
FSD_GH_APP_KEY: ${{ secrets.FSD_GH_APP_KEY }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main
with:
run_performance_tests: ${{ inputs.run_performance_tests || true }}
run_e2e_tests_assessment: ${{ inputs.run_e2e_tests_assessment || false }}
run_e2e_tests_application: ${{ inputs.run_e2e_tests_application || true }}
run_static_security_python: false
run_zap_scan: true
app_name: forms
environment: test
uat_deploy:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
needs:
[
setup,
docker-build,
dev_deploy,
post_dev_deploy_tests,
test_deploy,
post_test_deploy_tests,
]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'uat') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') ) }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main
secrets:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
with:
environment: "uat"
app_name: "form-runner"
version: sha-${{ github.sha }}
post_uat_deploy_tests:
needs:
[
setup,
docker-build,
dev_deploy,
post_dev_deploy_tests,
test_deploy,
post_test_deploy_tests,
uat_deploy,
]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'uat') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') ) }}
secrets:
FSD_GH_APP_ID: ${{ secrets.FSD_GH_APP_ID }}
FSD_GH_APP_KEY: ${{ secrets.FSD_GH_APP_KEY }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main
with:
run_performance_tests: ${{ inputs.run_performance_tests || true }}
run_e2e_tests_assessment: ${{ inputs.run_e2e_tests_assessment || false }}
run_e2e_tests_application: ${{ inputs.run_e2e_tests_application || true }}
run_static_security_python: false
run_zap_scan: true
app_name: forms
environment: uat
prod_deploy:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
needs:
[
setup,
docker-build,
dev_deploy,
post_dev_deploy_tests,
test_deploy,
post_test_deploy_tests,
uat_deploy,
post_uat_deploy_tests,
]
if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'prod') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') ) }}
uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main
secrets:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
with:
environment: "prod"
app_name: "form-runner"
version: sha-${{ github.sha }}