generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-migration.yml
97 lines (83 loc) · 2.87 KB
/
data-migration.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
name: Import Power Platform into Test
# Runs ad-hoc
trigger: none
pr: none
pool: hmcts-sds-ptl
parameters:
- name: environment
displayName: Environment
type: string
default: Staging
values:
- Staging
- Demo
- Production
- name: run_migration_script
displayName: Execute migration script
type: boolean
default: false
- name: run_recording_duration_script
displayName: Update recording duration
type: boolean
default: false
variables:
- name: 'environment'
value: ${{ parameters.environment }}
- name: 'serviceConnection'
${{ if eq(variables['environment'], 'Production') }}:
value: 'DTS-SHAREDSERVICES-PROD'
${{ if eq(variables['environment'], 'Demo') }}:
value: 'DTS-SHAREDSERVICES-DEMO'
${{ if eq(variables['environment'], 'Staging') }}:
value: 'DTS-SHAREDSERVICES-STG'
- name: 'envShortName'
${{ if eq(variables['environment'], 'Production') }}:
value: 'prod'
${{ if eq(variables['environment'], 'Demo') }}:
value: 'demo'
${{ if eq(variables['environment'], 'Staging') }}:
value: 'stg'
steps:
- task: AzureKeyVault@2
inputs:
azureSubscription: $(serviceConnection)
KeyVaultName: 'pre-hmctskv-$(envShortName)'
SecretsFilter: 'api-POSTGRES-USER,api-POSTGRES-PASS,api-POSTGRES-HOST,finalsa-storage-account-connection-string'
RunAsPreJob: true
- task: Bash@3
inputs:
targetType: 'inline'
script: |
echo "##vso[task.setvariable variable=LD_LIBRARY_PATH;]:{TOOLCACHE_PATH}/Python/{VERSION}/x64/lib/"
python3 --version
mkdir -p migration_reports/logs
touch migration_reports/logs/error.log
- script: pip install -r bin/migration/requirements.txt
displayName: 'Install dependencies'
- task: Bash@3
condition: ${{ eq(parameters.run_migration_script, true) }}
inputs:
targetType: 'inline'
script: |
export SOURCE_DB_NAME="pre-pdb-$(envShortName)"
export SOURCE_DB_USER="$(api-POSTGRES-USER)"
export SOURCE_DB_PASSWORD="$(api-POSTGRES-PASS)"
export SOURCE_DB_HOST="$(api-POSTGRES-HOST)"
export DESTINATION_DB_NAME="api"
export DESTINATION_DB_USER="$(api-POSTGRES-USER)"
export DESTINATION_DB_PASSWORD="$(api-POSTGRES-PASS)"
export DESTINATION_DB_HOST="$(api-POSTGRES-HOST)"
python3 bin/migration/main.py
displayName: 'Execute migration script'
- task: Bash@3
condition: ${{ eq(parameters.run_recording_duration_script, true) }}
inputs:
targetType: 'inline'
script: |
export DESTINATION_DB_NAME="api"
export DESTINATION_DB_USER="$(api-POSTGRES-USER)"
export DESTINATION_DB_PASSWORD="$(api-POSTGRES-PASS)"
export DESTINATION_DB_HOST="$(api-POSTGRES-HOST)"
export AZURE_STORAGE_CONNECTION_STRING="$(finalsa-storage-account-connection-string)"
python3 bin/migration/azure_storage_utils/main.py
displayName: 'Update recording duration'