This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
202 lines (163 loc) · 6.28 KB
/
static-selfserve-web-build-deploy.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
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
name: CI/CD STATIC SELFSERVE WEB
run-name: CI/CD STATIC SELFSERVE WEB
on:
pull_request_review:
types: [edited, submitted]
pull_request:
branches:
- master
env:
AWS_REGION : ${{ vars.DVSA_AWS_REGION }}
SSWEB_NONPROD_TOOLING_REPO_URL: ${{ secrets.SSWEB_NONPROD_TOOLING_ECR_REPO_URL }} #{account}.dkr.ecr.{region}.amazonaws.com/non-prod-vol-ssweb
AWS_ACCOUNT_ID_SHAREDCOREECR: ${{ vars.AWS_ACCOUNT_ID_SHAREDCOREECR }}
# Permission can be added at job level or workflow level
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
# security-events: write
jobs:
dockerfile-lint-check:
name: Dockerfile Lint Check
if: github.event_name == 'pull_request' && github.event_name != 'pull_request_review'
uses: dvsa/.github/.github/workflows/docker-hadolint.yaml@feature/AddMiscAuxilaryWorkflows
with:
dockerfile_name: dockerfile
supress_rule_list: DL3018,DL3048
# security:
# if: github.event_name == 'pull_request' && github.event_name != 'pull_request_review'
# uses: dvsa/.github/.github/workflows/[email protected]
# secrets:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# static-analysis:
# if: github.event_name == 'pull_request' && github.event_name != 'pull_request_review'
# uses: dvsa/.github/.github/workflows/[email protected]
# # with:
# # php-version: '7.4'
# tests:
# if: github.event_name == 'pull_request' && github.event_name != 'pull_request_review'
# uses: dvsa/.github/.github/workflows/[email protected]
# with:
# php-versions: "[\"7.4\"]"
# # fail-fast: false
unit-tests:
name: Run Unit Tests
if: github.event_name == 'pull_request' && github.event_name != 'pull_request_review'
runs-on: ubuntu-latest
steps:
- name: Checkout the repository to this runner
uses: actions/checkout@v3
- name: Run unit tests
run: |
echo 'Run unit tests'
ls -la ./
build-test-push-sign-image:
name: Build, Push & Sign Image
if: github.event_name == 'pull_request' && github.event_name != 'pull_request_review'
runs-on: ubuntu-latest
strategy:
matrix:
php:
- '7.4'
steps:
- name: Checkout the repository to this runner
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
- name: Build SelfServe Web artifact
uses: dvsa/olcs-selfserve/.github/actions/build-ssweb@feat/awsreset-container
- name: Set BASE_IMAGE & SSWEB_IMAGE_TAG
if: github.event.review.state == 'APPROVED'
run: |
envsubst < dockerfile | tee dockerfile.tmp
mv dockerfile.tmp dockerfile
BASE_IMAGE=$(head -n1 dockerfile)
echo "BASE_IMAGE=${BASE_IMAGE#* }" >> $GITHUB_ENV
echo "SSWEB_IMAGE_TAG=pr-approved-ssweb-${BASE_IMAGE#*:}-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Configure AWS credentials on Shared Core ECR
if: github.event.review.state == 'APPROVED'
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.DVSA_AWS_ROLE_SHAREDCORECR }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}
- name: Login to Shared Core ECR
if: github.event.review.state == 'APPROVED'
id: login-ecr-sharedcoreecr
uses: aws-actions/[email protected]
- name: Verify base image
if: github.event.review.state == 'APPROVED'
uses: dvsa/.github/.github/actions/image-integrity@feature/AddMiscAuxilaryWorkflows
with:
ecr_tagged_image: $BASE_IMAGE
image_sign_inspect: 'true'
- name: Build SelfServe Web image
if: github.event.review.state == 'APPROVED'
run: |
docker build -t ${SSWEB_NONPROD_TOOLING_REPO_URL}:${SSWEB_IMAGE_TAG} \
--build-arg DVSA_AWS_SHAREDCOREECR_ID=${{secrets.DVSA_AWS_SHAREDCOREECR_ID}} .
- name: Snyk scan SelfServe Web image
if: github.event.review.state == 'APPROVED'
id: scan-api-image
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: ${SSWEB_NONPROD_TOOLING_REPO_URL}:${SSWEB_IMAGE_TAG}
args: --file=dockerfile --severity-threshold=high
continue-on-error: true
- name: Configure AWS credentials on Non Production VOL ECR
if: github.event.review.state == 'APPROVED'
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.VOL_AWS_ROLE_TOOLING_NONPROD }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}
- name: Login to Non Production VOL ECR
if: github.event.review.state == 'APPROVED'
id: login-ecr-vol-tooling-non-prod
uses: aws-actions/[email protected]
- name: Push SelfServe Web image
if: github.event.review.state == 'APPROVED'
id: push-image
run: |
echo "image_tag=${SSWEB_IMAGE_TAG}" >> $GITHUB_OUTPUT
docker push ${SSWEB_NONPROD_TOOLING_REPO_URL}:${SSWEB_IMAGE_TAG}
outputs:
image_tag: ${{ steps.push-image.outputs.image_tag }}
deploy-on-static-cluster:
name: Deploy on Static ECS Cluster
if: github.event.review.state == 'APPROVED'
needs:
- dockerfile-lint-check
- unit-tests
# - security
# - static-analysis
# - tests
- build-test-push-sign-image
runs-on: ubuntu-latest
steps:
- name: Deploy
run: |
echo 'Deploy on Static'
# uses: dvsa/.github/.github/workflows/trigger-github-workflow.yaml@feature/AddMiscAuxilaryWorkflows
# with:
# branch: 'feature/AWSRESET1-514'
# git_repository: 'dvsa/dvsa-container-registry'
# workflow_name: 'CD NON-PROD SelfServe Web'
# input_arguments: 'ssweb_image_tag=${{ needs.build-test-push-sign-image.outputs.image_tag }}'
# secrets:
# gh_token: ${{ secrets.DVSA_VOL_TERRAFORM_ACCESS_TOKEN }}
automation-tests:
name: Run Automation Tests
if: github.event.review.state == 'APPROVED'
runs-on: ubuntu-latest
needs:
- deploy-on-static-cluster
steps:
- name: Run automation tests
run: |
echo 'Run automation tests'