-
Notifications
You must be signed in to change notification settings - Fork 1
185 lines (149 loc) · 6.13 KB
/
openshift-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
name: openshift deploy
run-name: Deploy ${{ inputs.MICROSERVICE_NAME }} to ${{ inputs.ENVIRONMENT_NAME}}
on:
workflow_dispatch:
inputs:
MICROSERVICE_NAME:
required: true
type: choice
options:
- cirras-underwriting-api
- cirras-underwriting-ui
- cirras-underwriting-jasper
ENVIRONMENT_NAME:
required: true
type: choice
options:
- dev
- qa
- dlvr
- test
- prod
NAMESPACE:
required: true
type: choice
options:
- a12541-dev
- a12541-test
- a12541-prod
TAG:
required: false
type: string
default: latest
workflow_call:
inputs:
MICROSERVICE_NAME:
required: true
type: string
ENVIRONMENT_NAME:
required: true
type: string
NAMESPACE:
required: true
type: string
TAG:
required: true
type: string
default: latest
jobs:
build:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.ENVIRONMENT_NAME }}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Copy openshift yaml files
run: mkdir staging && cp openshift/${{ inputs.MICROSERVICE_NAME }}*.yaml staging/
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ vars.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: update IMAGE NAME variable if needed
id: updateImageName
run: |
export IMAGE_NAME="$([ "${{inputs.MICROSERVICE_NAME}}" == "cirras-underwriting-ui" ] && echo 'cirras-underwriting-war' || echo 'cirras-underwriting-api')"
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_OUTPUT
- name: Get digest of docker image
id: getDigest
if: ${{ inputs.MICROSERVICE_NAME != 'cirras-underwriting-jasper'}}
run: |
export IMAGE='ghcr.io/${{github.repository_owner}}/${{ steps.updateImageName.outputs.IMAGE_NAME}}:${{ inputs.TAG }}'
docker pull $IMAGE
echo "IMAGE_BY_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' $IMAGE)" >> $GITHUB_OUTPUT
- name: Fill yaml files
uses: cschleiden/[email protected]
with:
files: staging/**.yaml
env:
#Common variables
LICENSE_PLATE: 'a12541'
#Vault path is different for prod than all other environments
VAULT_RESOURCE: ${{ inputs.NAMESPACE == 'a12541-prod' && 'prod' || 'nonprod' }}
ENV: ${{ inputs.ENVIRONMENT_NAME }}
NAMESPACE: ${{ inputs.NAMESPACE }}
TAG: ${{ inputs.TAG }}
IMAGE_BY_DIGEST: ${{ steps.getDigest.outputs.IMAGE_BY_DIGEST }}
SID: ${{ github.run_id }}
LOG_LEVEL: ${{ vars.LOG_LEVEL }}
CONNECTION_TIMEOUT: ${{ vars.CONNECTION_TIMEOUT }}
WEBADE_CHECK_TOKEN_URL: ${{ vars.WEBADE_CHECK_TOKEN_URL }}
WEBADE_GET_TOKEN_URL: ${{ vars.WEBADE_GET_TOKEN_URL }}
POSTGRES_USERNAME: ${{ vars.POSTGRES_USERNAME}}
#API variables
API_CPU_REQUEST: ${{ vars.API_CPU_REQUEST }}
API_CPU_LIMIT: ${{ vars.API_CPU_LIMIT }}
API_MEMORY_REQUEST: ${{ vars.API_MEMORY_REQUEST }}
API_MEMORY_LIMIT: ${{ vars.API_MEMORY_LIMIT }}
MAX_API_COUNT: ${{ vars.MAX_APP_COUNT }}
POSTGRES_RESOURCE_NAME: ${{ vars.POSTGRES_RESOURCE_NAME }}
TOMCAT_MAX_THREADS: ${{ vars.TOMCAT_MAX_THREADS }}
TOMCAT_PORT: ${{ vars.TOMCAT_PORT }}
TIME_ZONE: ${{ vars.TIME_ZONE }}
CIRRAS_POLICIES_API_URL: ${{ vars.CIRRAS_POLICIES_API_URL}}
CIRRAS_UNDERWRITING_REST_CLIENT_ID: ${{ vars.CIRRAS_UNDERWRITING_REST_CLIENT_ID }}
WEBADE_USERNAME: ${{ vars.WEBADE_USERNAME }}
WEBADE_MAXACTIVE: ${{ vars.WEBADE_MAXACTIVE }}
#DB/Liquibase variables:
POSTGRES_MAXACTIVE: '10'
CHANGELOG_FILE: changelog.json
#Frontend variables
MAX_UI_COUNT: ${{ vars.MAX_UI_COUNT }}
BASE_URL: https://cirras-underwriting-ui-route-${{ inputs.ENVIRONMENT_NAME }}-${{inputs.NAMESPACE}}.apps.silver.devops.gov.bc.ca/pub/cirras-underwriting/
CIRRAS_UNDERWRITING_REST_URI: https://cirras-underwriting-api-route-${{ inputs.ENVIRONMENT_NAME }}-${{inputs.NAMESPACE}}.apps.silver.devops.gov.bc.ca/cirras-underwriting-api/v1
ACTIVE_PORT: ${{ vars.TOMCAT_PORT }}
LOCAL_CHECKTOKEN_ENDPOINT: ${{ vars.LOCAL_CHECKTOKEN_ENDPOINT }}
WEBADE_OAUTH2_ENABLE_CHECKTOKEN: 'true'
WEBADE_OAUTH2_AUTHORIZE_URL: ${{ vars.WEBADE_OAUTH2_AUTHORIZE_URL }}
WEBADE_OAUTH2_SITEMINDER_URL: ${{ vars.WEBADE_OAUTH2_SITEMINDER_URL }}
WEBADE_OAUTH2_SCOPES: ${{ vars.WEBADE_OAUTH2_SCOPES }}
WEB_PATH: ${{ vars.WEB_PATH }}
#Jasper variables
JASPER_URL: cirras-underwriting-jasper-${{ inputs.ENVIRONMENT_NAME }}-${{ inputs.NAMESPACE }}.apps.silver.devops.gov.bc.ca
JASPER_USERNAME: ${{ vars.JASPER_USERNAME }}
JASPER_CPU_REQUEST: ${{ vars.JASPER_CPU_REQUEST }}
JASPER_CPU_LIMIT: ${{ vars.JASPER_CPU_LIMIT }}
JASPER_MEMORY_REQUEST: ${{ vars.JASPER_MEMORY_REQUEST }}
JASPER_MEMORY_LIMIT: ${{ vars.JASPER_MEMORY_LIMIT }}
ALLOW_EMPTY_PASSWORD: true
JASPERREPORTS_DATABASE_NAME: jasper${{ inputs.ENVIRONMENT_NAME }}
JASPERREPORTS_UI_USER: ${{ vars.JASPER_USERNAME }}
JASPER_STORAGE_CAPACITY: 25Mi
MARIADB_MAX_LOG_BYTES: ${{ vars.MARIADB_MAX_LOG_BYTES }}
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{secrets.OPENSHIFT_SERVER_URL}}
openshift_token: ${{secrets.OPENSHIFT_TOKEN}}
namespace: ${{ inputs.NAMESPACE }}
- name: Apply .yaml files to openshift
run: |
for file in staging/*
do
oc apply -f "$file"
done