-
Notifications
You must be signed in to change notification settings - Fork 1
229 lines (223 loc) · 10.1 KB
/
release_rotterdam_dev.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
name: Publish
on:
push:
branches: [ rotterdamdev ]
env:
awsaccountid: '871331361912'
awsregion: 'eu-west-1'
baseurl: 'p6-rotterdam-development.dcsa.org'
hostedzoneid: 'Z05135911NNH5LB9XHER0'
smtpusername: 'AKIA4VX3FOR4GF24KHPD'
cognitoappclientid: ''
cognitouserpoolid: ''
helmversion: '0.1.88'
dockerImageTag: 'live-dev'
helmChartName: 'dcsasandboxhamburg'
ingressChartName: 'dcsaingresscluster'
participantsfile: 'sqlscripts/rotterdam_participants.json'
deploydb: 'true'
jobs:
aws_cdk:
runs-on: ubuntu-latest
env:
smtppassword: ${{ secrets.ROTTERDAM_DEV_SMTPPASSWORD }}
participants: ${{ secrets.ROTTERDAM_DEV_PARTICIPANTS }}
awsaccesskeyid: ${{ secrets.ROTTERDAM_DEV_AWSACCESSKEYID }}
awssecretaccesskey: ${{ secrets.ROTTERDAM_DEV_AWSSECRETACCESSKEY }}
dbpassword: ${{ secrets.SANDBOX_DBPASSWORD }}
steps:
- name: Checkout the infrastructure code
uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-skip-session-tagging: true
aws-access-key-id: ${{ env.awsaccesskeyid }}
aws-secret-access-key: ${{ env.awssecretaccesskey }}
aws-region: ${{ env.awsregion }}
- name: Creating secret
run: |
aws secretsmanager create-secret --name DBPassword --secret-string ${{env.dbpassword}} || true
aws secretsmanager update-secret --secret-id DBPassword --secret-string ${{env.dbpassword}} || true
- name: CDK Bootstrapping AWS Account
uses: youyo/aws-cdk-github-actions@v2
with:
cdk_subcommand: 'bootstrap'
cdk_args: '--cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess'
cdk_stack: 'aws://${{ env.awsaccountid }}/${{ env.awsregion }}'
env:
AWS_ACCESS_KEY_ID: ${{ env.awsaccesskeyid }}
AWS_SECRET_ACCESS_KEY: ${{ env.awssecretaccesskey }}
PARTICIPANTS: ${{ env.participants }}
AWS_DEFAULT_REGION: ${{ env.awsregion }}
BASEURL: ''
HOSTEDZONEID: ''
SMTPUSERNAME: ''
SMTPPASSWORD: ''
EXPERIMENTAL: ''
- name: Check for CognitoStack
id: cognitoCheck
run: |
cognitoStackId=$(aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE | jq -r '.StackSummaries[] | select(.StackName|test("cognito")) | .StackId')
echo "::set-output name=cognitoStackId::$cognitoStackId"
- name: Extract values from UserPool
id: userPoolData
if: ${{ steps.cognitoCheck.outputs.cognitoStackId == '' }}
run: |
#!/usr/bin/env bash
# Ensure the script is executable in case it was edited on windows
script="./shell-scripts/extract-userpool-info.sh"
chmod a+x $script && $script
env:
EXISTING_USERPOOLID: ${{ env.cognitouserpoolid }}
EXISTING_UICLIENTID: ${{ env.cognitoappclientid }}
EXISTING_DCSACLIENTID: ${{ env.cognitodcsaclientid }}
EXISTING_DCSACLIENTSECRET: ${{ env.cognitodcsaclientsecret }}
EXISTING_TOKENURL: ${{ env.cognitotokenurl }}
- name: Deploying the CDK Cognito Code
uses: youyo/aws-cdk-github-actions@v2
if: ${{ steps.cognitoCheck.outputs.cognitoStackId == '' }}
with:
cdk_subcommand: 'deploy'
cdk_stack: 'cognito'
cdk_args: '--require-approval never'
actions_comment: false
env:
AWS_ACCESS_KEY_ID: ${{ env.awsaccesskeyid }}
AWS_SECRET_ACCESS_KEY: ${{ env.awssecretaccesskey }}
PARTICIPANTS: ${{ env.participants }}
AWS_DEFAULT_REGION: ${{ env.awsregion }}
BASEURL: ${{ env.baseurl }}
HOSTEDZONEID: ${{ env.hostedzoneid }}
HELMVERSION: ${{ env.helmversion }}
SMTPUSERNAME: ${{ env.smtpusername }}
SMTPPASSWORD: ${{ env.smtppassword }}
EXISTING_USERPOOLID: ${{ steps.userPoolData.outputs.userPoolId }}
EXISTING_UICLIENTID: ${{ steps.userPoolData.outputs.uiClientId }}
EXISTING_DCSACLIENTID: ${{ steps.userPoolData.outputs.dcsaClientId }}
EXISTING_DCSACLIENTSECRET: ${{ steps.userPoolData.outputs.dcsaClientSecret }}
EXISTING_TOKENURL: ${{ steps.userPoolData.outputs.tokenUrl }}
- name: Deploying the CDK DB RDS Code
uses: youyo/aws-cdk-github-actions@v2
if: ${{ env.deploydb == 'true' }}
with:
cdk_subcommand: 'deploy'
cdk_stack: 'db'
cdk_args: '--require-approval never'
actions_comment: false
env:
AWS_ACCESS_KEY_ID: ${{ env.awsaccesskeyid }}
AWS_SECRET_ACCESS_KEY: ${{ env.awssecretaccesskey }}
PARTICIPANTS: ${{ env.participants }}
AWS_DEFAULT_REGION: ${{ env.awsregion }}
BASEURL: ${{ env.baseurl }}
HOSTEDZONEID: ${{ env.hostedzoneid }}
HELMVERSION: ${{ env.helmversion }}
SMTPUSERNAME: ${{ env.smtpusername }}
SMTPPASSWORD: ${{ env.smtppassword }}
EXISTING_USERPOOLID: ${{ steps.userPoolData.outputs.userPoolId }}
EXISTING_UICLIENTID: ${{ steps.userPoolData.outputs.uiClientId }}
EXISTING_DCSACLIENTID: ${{ steps.userPoolData.outputs.dcsaClientId }}
EXISTING_DCSACLIENTSECRET: ${{ steps.userPoolData.outputs.dcsaClientSecret }}
EXISTING_TOKENURL: ${{ steps.userPoolData.outputs.tokenUrl }}
- name: Deploying the CDK Cluster Code
uses: youyo/aws-cdk-github-actions@v2
with:
cdk_subcommand: 'deploy'
cdk_stack: 'st'
cdk_args: '--require-approval never'
actions_comment: false
env:
AWS_ACCESS_KEY_ID: ${{ env.awsaccesskeyid }}
AWS_SECRET_ACCESS_KEY: ${{ env.awssecretaccesskey }}
PARTICIPANTS: ${{ env.participants }}
AWS_DEFAULT_REGION: ${{ env.awsregion }}
BASEURL: ${{ env.baseurl }}
HOSTEDZONEID: ${{ env.hostedzoneid }}
HELMVERSION: ${{ env.helmversion }}
SMTPUSERNAME: ${{ env.smtpusername }}
SMTPPASSWORD: ${{ env.smtppassword }}
- name: Kube secrets
run: |
#!/usr/bin/env bash
# Ensure the script is executable in case it was edited on windows
script="./shell-scripts/set-kubernetes-secrets.sh"
chmod a+x $script && $script
env:
DB_USER: postgres
DB_PASSWORD: ${{env.dbpassword}}
SMTPUSERNAME: ${{ env.smtpusername }}
SMTPPASSWORD: ${{ env.smtppassword }}
- name: SQL updates
if: ${{ env.deploydb == 'true' }}
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
sudo apt-get install jq
dburl=$(aws cloudformation describe-stacks --stack-name db | jq -c '.Stacks[0].Outputs[] | select(.OutputKey|test("EndpointHostname")) | .OutputValue' | tr -d '"')
echo $dburl
cat ${{ env.participantsfile }} | jq -c '.[]' | while read i; do
carrierinternal=$(echo $i | jq -c '.name' | tr -d '"')
echo $carrierinternal
suffix=""
carrier="$carrierinternal$suffix"
psql -h $dburl -U postgres -v dcsadbname="$carrier" -f sqlscripts/01_create_dcsa_owner.sql
psql -h $dburl -U postgres -v dcsadbname="$carrier" -f sqlscripts/02_create_database.sql
psql -h $dburl -U postgres -v dcsadbname="$carrier" -f sqlscripts/03_dcsa_im_v3_0.sql
psql -h $dburl -U postgres -v dcsadbname="$carrier" -f sqlscripts/04_load_reference_data.sql
psql -h $dburl -U postgres -v dcsadbname="$carrier" -f sqlscripts/05_reference_implementation_support.sql
psql -h $dburl -U postgres -v dcsadbname="$carrier" -f sqlscripts/06_phoney_ids.sql
psql -h $dburl -U postgres -v dcsadbname="$carrier" -f sqlscripts/07_load_sample_data.sql
done
env:
PGPASSWORD: ${{env.dbpassword}}
- name: HELM
run: |
#!/usr/bin/env bash
# Ensure the script is executable in case it was edited on windows
script="./shell-scripts/deploy-application.sh"
chmod a+x $script && $script
env:
DB_USER: postgres
DB_PASSWORD: ${{env.dbpassword}}
PARTICIPANTS: ${{ env.participants }}
BASEURL: ${{ env.baseurl }}
SMTPPASSWORD: ${{ env.smtppassword }}
SMTPUSERNAME: ${{ env.smtpusername }}
DOCKERIMAGETAG: ${{ env.dockerImageTag }}
HELMCHARTNAME: ${{ env.helmChartName }}
- name: HELM 2
run: |
#!/usr/bin/env bash
# Ensure the script is executable in case it was edited on windows
script="./shell-scripts/deploy-ingressalb.sh"
chmod a+x $script && $script
env:
DB_USER: postgres
DB_PASSWORD: ${{env.dbpassword}}
PARTICIPANTS: ${{ env.participants }}
BASEURL: ${{ env.baseurl }}
SMTPPASSWORD: ${{ env.smtppassword }}
SMTPUSERNAME: ${{ env.smtpusername }}
COGNITOAPPCLIENTID: ${{ env.cognitoappclientid }}
COGNITOUSERPOOLID: ${{ env.cognitouserpoolid }}
DOCKERIMAGETAG: ${{ env.dockerImageTag }}
INGRESSCHARTNAME: ${{ env.ingressChartName }}
- name: Updating load balancer dns
run: |
sleep 3m
alburl=$(aws elbv2 describe-load-balancers | grep "DNSName" | xargs | cut -d' ' -f2 | cut -d',' -f1)
echo $alburl
cat ${{ env.participantsfile }} | jq -c '.[]' | while read i; do
carrierinternal=$(echo $i | jq -c '.name' | tr -d '"')
echo $carrierinternal
carrierurl="$carrierinternal.$carrierbaseurl"
echo $carrierurl
cp ./route53/route53.json ./participantroute.json
sed -i "s#mydns#$alburl#g" ./participantroute.json
sed -i "s#carrierurl#$carrierurl#g" ./participantroute.json
cat ./participantroute.json
aws route53 change-resource-record-sets --hosted-zone-id ${{ env.hostedzoneid }} --change-batch file://./participantroute.json
done
env:
carrierbaseurl: ${{ env.baseurl }}