-
Notifications
You must be signed in to change notification settings - Fork 10
222 lines (214 loc) · 7.38 KB
/
delivery-ci.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
name: Delivery CI
on:
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
AFFECTED_BASE:
description: Value for --base= in nx affected commands
required: false
jobs:
build:
runs-on: ubuntu-20.04
outputs:
affected_apps: ${{ steps.set_outputs.outputs.affected_apps }}
affected_apps_array: ${{ steps.set_outputs.outputs.affected_apps_array }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7'
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: temurin
cache: maven
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: snok/install-poetry@v1
with:
version: '1.4.0'
- run: npm ci
- name: Get last successful commit
id: last_successful_commit
uses: nrwl/nx-set-shas@v3
- name: Build
id: production-build
uses: ./.github/actions/nx-production-build
with:
affected-base: ${{ github.event.inputs.AFFECTED_BASE || steps.last_successful_commit.outputs.base }}
github_token: ${{ secrets.GITHUB_TOKEN }}
npm_token: ${{ secrets.NPM_TOKEN }}
- run: npm prune --production
- if: steps.production-build.outputs.affected-apps
run: tar czf adsp-build-dist.tar.gz node_modules/ dist/
- if: steps.production-build.outputs.affected-apps
uses: actions/upload-artifact@v3
with:
name: build-dist
path: adsp-build-dist.tar.gz
# Set build job outputs for subsequent jobs.
- id: set_outputs
run: |
echo "affected_apps=${{ steps.production-build.outputs.affected-apps }}" >> $GITHUB_OUTPUT
echo "affected_apps_array=$(echo ${{ steps.production-build.outputs.affected-apps }} | sed -e "s/ /\",\"/g" -e "s/^/[\"/" -e "s/$/\"]/")" >> $GITHUB_OUTPUT
buildContainers:
runs-on: ubuntu-20.04
needs: build
if: needs.build.outputs.affected_apps
strategy:
fail-fast: false
matrix:
app: ${{ fromJson(needs.build.outputs.affected_apps_array) }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-dist
path: ./
- run: tar -xf adsp-build-dist.tar.gz
- name: Build container
uses: ./.github/actions/build-publish-container
with:
app: ${{ matrix.app }}
redhat-io-username: ${{ secrets.REGISTRY_REDHAT_IO_USER }}
redhat-io-password: ${{ secrets.REGISTRY_REDHAT_IO_PASSWORD }}
build-context: ${{ hashFiles(format('./dist/apps/{0}/nginx.conf', matrix.app)) && format('./dist/apps/{0}', matrix.app) || './' }}
container-file: ${{ hashFiles(format('./apps/{0}/Dockerfile', matrix.app)) && format('./apps/{0}/Dockerfile', matrix.app) || './.openshift/service/Dockerfile' }}
ghcr-token: ${{ secrets.GITHUB_TOKEN }}
deployDev:
runs-on: ubuntu-20.04
needs: [build, buildContainers]
env:
AFFECTED_APPS: ${{ needs.build.outputs.affected_apps }}
environment:
name: Dev
steps:
- uses: actions/checkout@v3
- name: Oc login
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.ARO_SERVER }}
openshift_token: ${{ secrets.ARO_TOKEN }}
namespace: adsp-build
insecure_skip_tls_verify: true
- name: Tag Dev
run: |
for app in $AFFECTED_APPS
do
oc import-image ghcr.io/govalta/$app:latest --reference-policy='local' --confirm
oc tag $app:latest $app:dev --reference-policy='local'
done
- run: oc project adsp-dev
- name: Apply Manifests
run: |
for app in $AFFECTED_APPS
do
oc process -f .openshift/managed/$app.yml -p INFRA_NAMESPACE=adsp-build -p NAMESPACE=adsp-dev -p DEPLOY_TAG=dev > $app.dev.json
oc apply -f $app.dev.json -l apply-dev=true,component!=database
done
- name: Deploy Dev
run: |
for app in $AFFECTED_APPS
do
oc rollout latest dc/$app
oc rollout status dc/$app
done
devSmokeTest:
runs-on: ubuntu-20.04
needs: [build, deployDev]
environment:
name: Dev-e2e
strategy:
matrix:
app: [tenant-management-webapp, status-app, subscriber-app]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: E2E Test
uses: ./.github/actions/nx-cypress-e2e
with:
app: ${{ matrix.app }}
environment: dev
tags: '@smoke-test and not @ignore'
core-api-client-secret: ${{ secrets.CY_CORE_API_CLIENT_SECRET }}
core-api-user-password: ${{ secrets.CY_CORE_API_USER_PASSWORD }}
api-client-secret: ${{ secrets.CY_CLIENT_SECRET }}
cy-password: ${{ secrets.CY_PASSWORD }}
cy-password-2: ${{ secrets.CY_PASSWORD2 }}
cy-password-3: ${{ secrets.CY_PASSWORD3 }}
deployStaging:
runs-on: ubuntu-20.04
needs: [build, devSmokeTest]
env:
AFFECTED_APPS: ${{ needs.build.outputs.affected_apps }}
environment:
name: Staging
steps:
- uses: actions/checkout@v3
- name: Oc login
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.ARO_SERVER }}
openshift_token: ${{ secrets.ARO_TOKEN }}
namespace: adsp-build
insecure_skip_tls_verify: true
- name: Tag Staging
run: |
for app in $AFFECTED_APPS
do
oc tag $app:dev $app:uat --reference-policy='local'
done
- run: oc project adsp-uat
- name: Apply Manifests
run: |
for app in $AFFECTED_APPS
do
oc process -f .openshift/managed/$app.yml -p INFRA_NAMESPACE=adsp-build -p NAMESPACE=adsp-uat -p DEPLOY_TAG=uat > $app.uat.json
oc apply -f $app.uat.json -l apply-staging=true,component!=database
done
- name: Deploy Staging
run: |
for app in $AFFECTED_APPS
do
oc rollout latest dc/$app
oc rollout status dc/$app
done
stagingSmokeTest:
runs-on: ubuntu-20.04
needs: [build, deployStaging]
environment:
name: Staging-e2e
strategy:
matrix:
app: [tenant-management-webapp, status-app, subscriber-app]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: E2E Test
uses: ./.github/actions/nx-cypress-e2e
with:
app: ${{ matrix.app }}
environment: staging
tags: '@smoke-test and not @ignore'
core-api-client-secret: ${{ secrets.CY_CORE_API_CLIENT_SECRET }}
core-api-user-password: ${{ secrets.CY_CORE_API_USER_PASSWORD }}
api-client-secret: ${{ secrets.CY_CLIENT_SECRET }}
cy-password: ${{ secrets.CY_PASSWORD }}
cy-password-2: ${{ secrets.CY_PASSWORD2 }}
cy-password-3: ${{ secrets.CY_PASSWORD3 }}