-
Notifications
You must be signed in to change notification settings - Fork 10
153 lines (148 loc) · 5.4 KB
/
promote.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
name: Promote Apps
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
SKIP_REGRESSION:
description: Flag indicating if regression should be skipped.
type: boolean
required: false
default: false
APPS:
description: APPS to promote.
required: false
jobs:
affected:
runs-on: ubuntu-22.04
outputs:
affected_apps: ${{ steps.set_outputs.outputs.affected_apps }}
affected_apps_array: ${{ steps.set_outputs.outputs.affected_apps_array }}
env:
AFFECTED_APPS: ''
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9'
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- name: Get last successful commit
uses: nrwl/nx-set-shas@v3
id: last_successful_commit
with:
last-successful-event: workflow_dispatch
- name: Get affected apps
shell: bash
run: echo "AFFECTED_APPS=$(npx nx show projects --affected --type=app --base=${{ steps.last_successful_commit.outputs.base }} | tr "\n" " ")" >> $GITHUB_ENV
- name: Set outputs for downstream
id: set_outputs
shell: bash
run: |
echo "affected_apps=${{ github.event.inputs.APPS || env.AFFECTED_APPS }}" >> $GITHUB_OUTPUT
echo "affected_apps_array=$(echo ${{ github.event.inputs.APPS || env.AFFECTED_APPS }} | sed -e "s/ /\",\"/g" -e "s/^/[\"/" -e "s/$/\"]/")" >> $GITHUB_OUTPUT
stagingRegression:
runs-on: ubuntu-22.04
needs: affected
if: needs.affected.outputs.affected_apps
environment:
name: Staging-e2e
strategy:
matrix:
app: [tenant-management-webapp, status-app, subscriber-app]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: E2E Test
uses: ./.github/actions/nx-cypress-e2e
if: github.event.inputs.SKIP_REGRESSION != 'true'
with:
app: ${{ matrix.app }}
environment: staging
tags: '@regression 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 }}
deployProduction:
runs-on: ubuntu-22.04
needs: [affected, stagingRegression]
strategy:
fail-fast: true
max-parallel: 2
matrix:
app: ${{ fromJson(needs.affected.outputs.affected_apps_array) }}
environment:
name: Production
steps:
- uses: actions/checkout@v4
- 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 Production
run: oc tag ${{ matrix.app }}:uat ${{ matrix.app }}:prod --reference-policy='local'
- run: oc project adsp-prod
- name: Apply Manifests
run: |
oc process -f .openshift/managed/${{ matrix.app }}.yml -p INFRA_NAMESPACE=adsp-build -p NAMESPACE=adsp-prod -p DEPLOY_TAG=prod > ${{ matrix.app }}.prod.json
oc apply -f ${{ matrix.app }}.prod.json -l apply-prod=true,component!=database
- name: Deploy Production
run: |
if oc get dc/${{ matrix.app }} ; then
oc rollout latest dc/${{ matrix.app }}
oc rollout status dc/${{ matrix.app }}
elif oc get deployment/${{ matrix.app }} ; then
oc set triggers deployment/${{ matrix.app }} --auto
oc rollout status deployment/${{ matrix.app }}
oc set triggers deployment/${{ matrix.app }} --manual
else
echo 'No DeploymentConfig or Deployment found for ${{ matrix.app }}.'
fi
smokeTestProd:
runs-on: ubuntu-22.04
needs: deployProduction
environment:
name: Prod-e2e
strategy:
matrix:
app: [tenant-management-webapp, status-app, subscriber-app]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: E2E Test
uses: ./.github/actions/nx-cypress-e2e
with:
app: ${{ matrix.app }}
environment: prod
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 }}