Skip to content

Deploy OpenCRVS on dev (core: v1.9.0-beta-1, country: v1.9.0-beta-1) #26

Deploy OpenCRVS on dev (core: v1.9.0-beta-1, country: v1.9.0-beta-1)

Deploy OpenCRVS on dev (core: v1.9.0-beta-1, country: v1.9.0-beta-1) #26

Workflow file for this run

name: Deploy OpenCRVS
run-name: "Deploy OpenCRVS on ${{ inputs.environment }} (core: ${{ inputs.core-image-tag }}, country: ${{ inputs.countryconfig-image-tag }})"
on:
workflow_call:
inputs:
core-image-tag:
type: string
countryconfig-image-tag:
type: string
environment:
type: string
reset:
type: boolean
deploy_mosip:
type: boolean
workflow_dispatch:
inputs:
core-image-tag:
description: "Tag of the core image"
required: true
default: "develop"
countryconfig-image-tag:
description: "Tag of the countryconfig image"
required: true
default: "develop"
environment:
description: "Target environment"
required: true
default: "dev"
type: choice
options:
- demo
- dev
reset:
description: "Reset environment after deploy"
required: false
default: false
type: boolean
deploy_mosip:
description: "Deploy MOSIP integration"
required: false
default: false
type: boolean
jobs:
github-to-k8s-sync-env:
uses: ./.github/workflows/github-to-k8s-sync-env.yml
with:
environment: ${{ inputs.environment }}
secrets: inherit
deploy:
needs: github-to-k8s-sync-env
environment: ${{ inputs.environment }}
env:
ENV: ${{ inputs.environment }}
BRANCH: ${{ github.ref_name }}
CORE_IMAGE_TAG: ${{ inputs.core-image-tag }}
COUNTRYCONFIG_IMAGE_TAG: ${{ inputs.countryconfig-image-tag }}
COUNTRYCONFIG_IMAGE_NAME: ${{ secrets.DOCKERHUB_ACCOUNT || 'opencrvs' }}/${{ secrets.DOCKERHUB_REPO || 'ocrvs-farajaland'}}
runs-on:
- self-hosted
- k8s
- ${{ inputs.environment }}
steps:
- uses: actions/checkout@v5
- name: Generate summary
run: |
echo "Deploying environment to https://${{ vars.DOMAIN }}" >> $GITHUB_STEP_SUMMARY
echo "Core image tag: ${{ inputs.core-image-tag }}" >> $GITHUB_STEP_SUMMARY
echo "Country config image tag: ${{ inputs.countryconfig-image-tag }}" >> $GITHUB_STEP_SUMMARY
echo "Reset environment: ${{ inputs.reset }}" >> $GITHUB_STEP_SUMMARY
- name: Print deployment parameters
run: |
echo "Environment: $ENV"
echo "Core Image: $CORE_IMAGE_TAG"
echo "Country Config Image: $COUNTRYCONFIG_IMAGE_TAG"
echo "base_ref: ${{ github.base_ref }}"
echo "branch: ${BRANCH}"
- name: Deploy OpenCRVS MOSIP API
if: inputs.deploy_mosip
run: |
helm upgrade --install mosip-api oci://ghcr.io/opencrvs/opencrvs-mosip \
--namespace "opencrvs-${ENV}" \
-f environments/${ENV}/mosip-api/values.yaml \
--set hostname=${{ vars.DOMAIN }} \
--create-namespace \
--atomic
- name: "FIXME: temporary remove data-migration job due to issues"
run: |
kubectl delete job -n "opencrvs-${ENV}" --ignore-not-found=true data-migration || true
- name: Deploy with Helm
run: |
helm upgrade --install opencrvs oci://ghcr.io/opencrvs/opencrvs-services \
--timeout 15m \
--namespace "opencrvs-${ENV}" \
-f environments/${ENV}/opencrvs-services/values.yaml \
--create-namespace \
--atomic \
--wait \
--wait-for-jobs \
--set image.tag="$CORE_IMAGE_TAG" \
--set countryconfig.image.tag="$COUNTRYCONFIG_IMAGE_TAG" \
--set countryconfig.image.name="$COUNTRYCONFIG_IMAGE_NAME" \
--set hostname=${{ vars.DOMAIN }}
- name: Cleanup Helm Locks
if: failure() || cancelled()
run: |
kubectl -n "opencrvs-${ENV}" get secrets -l owner=helm -o json | \
jq -r '.items[] | select(.metadata.labels.status=="pending-install" or .metadata.labels.status=="pending-upgrade") | .metadata.name' | \
xargs -r kubectl -n "opencrvs-${ENV}" delete secret || \
echo "No helm locks found, all is good"
reset-data:
if: ${{ inputs.reset }}
needs: deploy
uses: ./.github/workflows/k8s-reset-data.yml
with:
environment: ${{ inputs.environment }}
secrets: inherit