Reset data on qa #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
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 }} | |
STACK: ${{ inputs.stack }} | |
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 $STACK" | |
echo "Running migrations..." | |
echo | |
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $SSH_ARGS " | |
ELASTICSEARCH_ADMIN_USER=elastic \ | |
ELASTICSEARCH_ADMIN_PASSWORD=$ELASTICSEARCH_SUPERUSER_PASSWORD \ | |
/opt/opencrvs/infrastructure/run-migrations.sh" |