-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (85 loc) · 3.21 KB
/
clear-environment.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
name: Reset environment
run-name: Reset data on ${{ github.event.inputs.environment }}
on:
workflow_call:
inputs:
environment:
required: true
type: string
stack:
required: true
type: string
outputs:
outcome:
value: ${{ jobs.reset-data.outputs.outcome }}
workflow_dispatch:
inputs:
stack:
type: string
description: Stack name
required: true
environment:
type: choice
description: Environment to reset
required: true
default: 'qa'
options:
- qa
jobs:
reset-data:
name: 'Reset data from stack ${{ inputs.stack }} in ${{ inputs.environment }}'
environment: ${{ inputs.environment }}
runs-on: ubuntu-22.04
outputs:
outcome: ${{ steps.reset-data.outcome }}
timeout-minutes: 60
steps:
- name: Clone country config resource package
uses: actions/checkout@v3
with:
fetch-depth: 1
path: './${{ github.event.repository.name }}'
- name: Read known hosts
run: |
cd ${{ github.event.repository.name }}
echo "KNOWN_HOSTS<<EOF" >> $GITHUB_ENV
sed -i -e '$a\' ./infrastructure/known-hosts
cat ./infrastructure/known-hosts >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ env.KNOWN_HOSTS }}
- name: Reset data
id: reset-data
env:
HOST: ${{ vars.DOMAIN }}
ENV: ${{ vars.ENVIRONMENT_TYPE }}
SSH_USER: ${{ secrets.SSH_USER }}
# SSH_HOST was moved from a secret to a variable in OpenCRVS 1.5.0
# @todo @deprecated remove the fallback to secrets.SSH_HOST in OpenCRVS 1.7.0
SSH_HOST: ${{ vars.SSH_HOST || secrets.SSH_HOST }}
# SSH_PORT was moved from a secret to a variable in OpenCRVS 1.5.0
# @todo @deprecated remove the fallback to secrets.SSH_PORT in OpenCRVS 1.7.0
SSH_PORT: ${{ vars.SSH_PORT || secrets.SSH_PORT }}
REPLICAS: ${{ vars.REPLICAS }}
MONGODB_ADMIN_USER: ${{ secrets.MONGODB_ADMIN_USER }}
MONGODB_ADMIN_PASSWORD: ${{ secrets.MONGODB_ADMIN_PASSWORD }}
ELASTICSEARCH_SUPERUSER_PASSWORD: ${{ secrets.ELASTICSEARCH_SUPERUSER_PASSWORD }}
MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
SSH_ARGS: ${{ vars.SSH_ARGS }}
run: |
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $SSH_ARGS "
ELASTICSEARCH_ADMIN_USER=elastic \
ELASTICSEARCH_ADMIN_PASSWORD=$ELASTICSEARCH_SUPERUSER_PASSWORD \
MONGODB_ADMIN_USER=$MONGODB_ADMIN_USER \
MONGODB_ADMIN_PASSWORD=$MONGODB_ADMIN_PASSWORD \
MINIO_ROOT_USER=$MINIO_ROOT_USER \
MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD \
/opt/opencrvs/infrastructure/clear-all-data.sh $REPLICAS ${{ inputs.stack }}"
echo "Running migrations..."
echo
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $SSH_ARGS "
/opt/opencrvs/infrastructure/run-migrations.sh ${{ inputs.stack }}"