Skip to content

Commit

Permalink
Merge pull request #6 from opencrvs/develop
Browse files Browse the repository at this point in the history
Merge Release-v1.3.0 into master
  • Loading branch information
euanmillar authored Oct 2, 2023
2 parents 0e8d576 + 457cc02 commit 05f5ed5
Show file tree
Hide file tree
Showing 314 changed files with 37,478 additions and 35,175 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Deploy(production)
run-name: Deploy to ${{ github.event.inputs.environment }} core=${{ github.event.inputs.core-image-tag }} country config=${{ github.event.inputs.countryconfig-image-tag }}
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: Environment to deploy to
required: true
default: 'production'
options:
- production
core-image-tag:
description: Core DockerHub image tag
required: true
default: 'v1.3.0'
countryconfig-image-tag:
description: Your Country Config DockerHub image tag
required: true
deploy-script-environment:
type: choice
description: Deploy script environment
required: true
default: 'production'
options:
- production
- demo
jobs:
deploy:
environment: ${{ github.event.inputs.environment }}
runs-on: ubuntu-20.04
timeout-minutes: 60
strategy:
matrix:
node-version: [16.20.0]
steps:
- name: Clone core
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: 'opencrvs/opencrvs-core'
path: './opencrvs-core'
- name: Clone country config resource package
uses: actions/checkout@v3
with:
fetch-depth: 0
path: './${{ github.event.repository.name }}'

- name: Checkout country branch
run: |
cd ${{ github.event.repository.name }}
git checkout ${{ github.event.inputs.countryconfig-image-tag }}
cd ../
- name: Checkout core branch
run: |
cd opencrvs-core
git checkout ${{ github.event.inputs.core-image-tag }}
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Wait for images to be available
run: |
while true; do
if docker manifest inspect opencrvs/ocrvs-auth:${{ github.event.inputs.core-image-tag }}; then
break
fi
sleep 10
done
while true; do
if docker manifest inspect opencrvs/ocrvs-farajaland:${{ github.event.inputs.countryconfig-image-tag }}; then
break
fi
sleep 10
done

- name: Deploy to ${{ github.event.inputs.environment }}
env:
DOMAIN: ${{ vars.DOMAIN }}
REPLICAS: ${{ vars.REPLICAS }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
ALERT_EMAIL: ${{ secrets.ALERT_EMAIL }}
DOCKERHUB_ACCOUNT: ${{ secrets.DOCKERHUB_ACCOUNT }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }}
KIBANA_USERNAME: ${{ secrets.KIBANA_USERNAME }}
KIBANA_PASSWORD: ${{ secrets.KIBANA_PASSWORD }}
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 }}
EMAIL_API_KEY: ${{ secrets.EMAIL_API_KEY }}
INFOBIP_SENDER_ID: ${{ secrets.INFOBIP_SENDER_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
INFOBIP_GATEWAY_ENDPOINT: ${{ secrets.INFOBIP_GATEWAY_ENDPOINT }}
INFOBIP_API_KEY: ${{ secrets.INFOBIP_API_KEY }}
SENDER_EMAIL_ADDRESS: ${{ secrets.SENDER_EMAIL_ADDRESS }}
SUPER_USER_PASSWORD: ${{ secrets.SUPER_USER_PASSWORD }}
run: |
cd ./${{ github.event.repository.name }}
yarn deploy --clear_data=no --environment=${{ github.event.inputs.deploy-script-environment }} --host=${{ env.DOMAIN }} --version=${{ github.event.inputs.core-image-tag }} --country_config_version=${{ github.event.inputs.countryconfig-image-tag }} --country_config_path=../${{ github.event.repository.name }} --replicas=${{ env.REPLICAS }}
129 changes: 58 additions & 71 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Deploy

name: Deploy(development)
run-name: Deploy to ${{ github.event.inputs.environment }} with reset=${{ github.event.inputs.reset }} core=${{ github.event.inputs.core-image-tag }} country config=${{ github.event.inputs.countryconfig-image-tag }}
on:
workflow_dispatch:
inputs:
Expand All @@ -11,22 +11,31 @@ on:
options:
- staging
- qa
- production
core-image-tag:
description: Core DockerHub image tag
required: false
default: 'v1.2.0'
required: true
default: 'v1.3.0'
countryconfig-image-tag:
description: Your Country Config DockerHub image tag
required: true
reset:
type: choice
description: Whether to reset the environment
required: true
default: 'no'
options:
- 'yes'
- 'no'
jobs:
deploy:
environment: ${{ github.event.inputs.environment }}
runs-on: ubuntu-20.04
outputs:
outcome: ${{ steps.deploy.outcome }}
timeout-minutes: 60
strategy:
matrix:
node-version: [14.17.0]
node-version: [16.20.0]
steps:
- name: Clone core
uses: actions/checkout@v3
Expand All @@ -40,87 +49,50 @@ jobs:
fetch-depth: 0
path: './${{ github.event.repository.name }}'

- name: Set COUNTRY_CONFIG_VERSION from inputs
if: ${{ github.event.inputs.countryconfig-image-tag }}
- name: Checkout country branch
run: |
cd ${{ github.event.repository.name }}
echo "COUNTRY_CONFIG_VERSION=${{ github.event.inputs.countryconfig-image-tag }}" >> $GITHUB_ENV
git checkout ${{ github.event.inputs.countryconfig-image-tag }}
cd ../
- name: Set CORE_VERSION from inputs
if: ${{ github.event.inputs.core-image-tag }}
- name: Checkout core branch
run: |
cd opencrvs-core
git checkout ${{ github.event.inputs.core-image-tag }}
echo "CORE_VERSION=${{ github.event.inputs.core-image-tag }}" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}

- name: Deploy to QA
if: ${{ github.event.inputs.environment == 'qa' }}
env:
QA_DOMAIN: ${{ secrets.QA_DOMAIN }}
FACTORY_RESET: ${{ secrets.FACTORY_RESET }}
REPLICAS: ${{ secrets.REPLICAS }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
ALERT_EMAIL: ${{ secrets.ALERT_EMAIL }}
DOCKERHUB_ACCOUNT: ${{ secrets.DOCKERHUB_ACCOUNT }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }}
KIBANA_USERNAME: ${{ secrets.KIBANA_USERNAME }}
KIBANA_PASSWORD: ${{ secrets.KIBANA_PASSWORD }}
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 }}
run: |
cd opencrvs-core
bash deploy.sh --clear-data=${{ env.FACTORY_RESET }} --restore-metadata=${{ env.FACTORY_RESET }} qa ${{ env.QA_DOMAIN }} ${{ env.CORE_VERSION }} ${{ env.COUNTRY_CONFIG_VERSION }} ../${{ github.event.repository.name }} ${{ env.REPLICAS }}
- name: Deploy to production
if: ${{ github.event.inputs.environment == 'production' }}
env:
PRODUCTION_DOMAIN: ${{ secrets.PRODUCTION_DOMAIN }}
FACTORY_RESET: ${{ secrets.FACTORY_RESET }}
REPLICAS: ${{ secrets.REPLICAS }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
ALERT_EMAIL: ${{ secrets.ALERT_EMAIL }}
DOCKERHUB_ACCOUNT: ${{ secrets.DOCKERHUB_ACCOUNT }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }}
KIBANA_USERNAME: ${{ secrets.KIBANA_USERNAME }}
KIBANA_PASSWORD: ${{ secrets.KIBANA_PASSWORD }}
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 }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Wait for images to be available
run: |
cd opencrvs-core
bash deploy.sh --clear-data=${{ env.FACTORY_RESET }} --restore-metadata=${{ env.FACTORY_RESET }} production ${{ env.PRODUCTION_DOMAIN }} ${{ env.CORE_VERSION }} ${{ env.COUNTRY_CONFIG_VERSION }} ../${{ github.event.repository.name }} ${{ env.REPLICAS }}
while true; do
if docker manifest inspect opencrvs/ocrvs-auth:${{ github.event.inputs.core-image-tag }}; then
break
fi
sleep 10
done
while true; do
if docker manifest inspect opencrvs/ocrvs-farajaland:${{ github.event.inputs.countryconfig-image-tag }}; then
break
fi
sleep 10
done

- name: Deploy to staging
if: ${{ github.event.inputs.environment == 'staging' }}
- name: Deploy to ${{ github.event.inputs.environment }}
id: deploy
env:
STAGING_DOMAIN: ${{ secrets.STAGING_DOMAIN }}
FACTORY_RESET: ${{ secrets.FACTORY_RESET }}
REPLICAS: ${{ secrets.REPLICAS }}
DOMAIN: ${{ vars.DOMAIN }}
REPLICAS: ${{ vars.REPLICAS }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
Expand All @@ -135,6 +107,21 @@ jobs:
ELASTICSEARCH_SUPERUSER_PASSWORD: ${{ secrets.ELASTICSEARCH_SUPERUSER_PASSWORD }}
MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
EMAIL_API_KEY: ${{ secrets.EMAIL_API_KEY }}
INFOBIP_SENDER_ID: ${{ secrets.INFOBIP_SENDER_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
INFOBIP_GATEWAY_ENDPOINT: ${{ secrets.INFOBIP_GATEWAY_ENDPOINT }}
INFOBIP_API_KEY: ${{ secrets.INFOBIP_API_KEY }}
SENDER_EMAIL_ADDRESS: ${{ secrets.SENDER_EMAIL_ADDRESS }}
SUPER_USER_PASSWORD: ${{ secrets.SUPER_USER_PASSWORD }}
run: |
cd opencrvs-core
bash deploy.sh --clear-data=${{ env.FACTORY_RESET }} --restore-metadata=${{ env.FACTORY_RESET }} development ${{ env.STAGING_DOMAIN }} ${{ env.CORE_VERSION }} ${{ env.COUNTRY_CONFIG_VERSION }} ../${{ github.event.repository.name }} ${{ env.REPLICAS }}
cd ./${{ github.event.repository.name }}
yarn deploy --clear_data=${{ github.event.inputs.reset }} --environment=${{ github.event.inputs.environment }} --host=${{ env.DOMAIN }} --version=${{ github.event.inputs.core-image-tag }} --country_config_version=${{ github.event.inputs.countryconfig-image-tag }} --country_config_path=../${{ github.event.repository.name }} --replicas=${{ env.REPLICAS }}
seed-data:
needs: deploy
if: ${{ github.event.inputs.reset == 'yes' && needs.deploy.outputs.outcome == 'success' }}
uses: ./.github/workflows/seed-data.yml
with:
environment: ${{ github.event.inputs.environment }}
core-image-tag: ${{ github.event.inputs.core-image-tag }}
secrets: inherit
17 changes: 6 additions & 11 deletions .github/workflows/generate-demo-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# OpenCRVS is also distributed under the terms of the Civil Registration
# & Healthcare Disclaimer located at http://opencrvs.org/license.
#
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
# graphic logo are (registered/a) trademark(s) of Plan International.
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
name: Generate demo data

on:
Expand All @@ -16,9 +15,6 @@ on:
description: 'Branch to run from'
required: false
default: 'develop'
districts:
description: 'District ids separated by comma'
required: false
environment:
type: choice
description: Environment to deploy to
Expand All @@ -45,9 +41,8 @@ jobs:
- name: Start generating test data
run: yarn data-generator
env:
DISTRICTS: ${{ github.event.inputs.districts }}
COUNTRY_CONFIG_HOST: ${{ secrets.COUNTRY_CONFIG_HOST }}
AUTH_API_HOST: ${{ secrets.AUTH_API_HOST }}
GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }}
CONFIG_HOST: ${{ secrets.CONFIG_HOST }}
CONCURRENCY: ${{ secrets.CONCURRENCY }}
COUNTRY_CONFIG_HOST: ${{ vars.COUNTRY_CONFIG_HOST }}
AUTH_HOST: ${{ vars.AUTH_HOST }}
GATEWAY_HOST: ${{ vars.GATEWAY_HOST }}
CONFIG_HOST: ${{ vars.CONFIG_HOST }}
CONCURRENCY: ${{ vars.CONCURRENCY }}
44 changes: 44 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish release

on:
workflow_dispatch:
inputs:
branch_name:
description: Branch to build from
default: develop
required: true
release_version:
description: Release version number
required: true

jobs:
base:
runs-on: ubuntu-latest
steps:
- uses: trstringer/manual-approval@v1
with:
secret: ${{ github.TOKEN }}
approvers: euanmillar,rikukissa
minimum-approvals: 1
issue-title: "Release: ${{ github.event.inputs.release_version }}"
issue-body: "Please approve or deny the publishing of release: ${{ github.event.inputs.release_version }} to Dockerhub"
exclude-workflow-initiator-as-approver: false
- uses: actions/checkout@v2
if: github.event_name == 'workflow_dispatch'
with:
ref: '${{ github.event.inputs.branch_name }}'
- uses: actions/checkout@v2
if: github.event_name == 'push'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push image
env:
DOCKERHUB_ACCOUNT: ${{ secrets.DOCKERHUB_ACCOUNT }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }}
run: |
export COUNTRY_CONFIG_VERSION=${{ github.event.inputs.release_version }}
echo "Publishing a Docker image with a tag $COUNTRY_CONFIG_VERSION"
bash build-and-push.sh && unset COUNTRY_CONFIG_VERSION
Loading

0 comments on commit 05f5ed5

Please sign in to comment.