Adds type
filter to Medibase search (#1566)
#917
Workflow file for this run
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: Deploy Care | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
- production | |
paths-ignore: | |
- "docs/**" | |
env: | |
IMAGE_NAME: care | |
AWS_DEFAULT_REGION: ap-south-1 | |
AWS_DEFAULT_OUTPUT: json | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID}} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
EKS_CLUSTER_NAME: ${{ secrets.AWS_EKS_CLUSTER_NAME }} | |
ECS_SERVICE_BACKEND: "care-backend" | |
ECS_SERVICE_CELERY: "care-celery" | |
ECS_CLUSTER: "egov" | |
ECS_TASK_DEFINITION_BACKEND: "./aws/backend.json" | |
ECS_TASK_DEFINITION_CELERY: "./aws/celery.json" | |
CONTAINER_NAME_BACKEND: "care-backend" | |
CONTAINER_NAME_WORKER: "care-celery-worker" | |
CONTAINER_NAME_CRON: "care-celery-beat" | |
jobs: | |
test: | |
if: github.repository == 'coronasafe/care' && (github.ref == 'refs/heads/production' || github.ref == 'refs/heads/master') | |
runs-on: ubuntu-latest | |
env: | |
DATABASE_URL: postgres://postgres:postgres@localhost:5432/care | |
name: Test | |
services: | |
db: | |
image: postgres:latest | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: care | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
redis: | |
image: redis:alpine | |
ports: | |
- 6379:6379 | |
localstack: | |
image: localstack/localstack:latest | |
env: | |
AWS_DEFAULT_REGION: ap-south-1 | |
EDGE_PORT: 4566 | |
SERVICES: s3 | |
ports: | |
- 4566:4566 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Test build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile | |
push: false | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | |
- name: Cache pip | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
${{ runner.os }}- | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install binutils libproj-dev libjpeg-dev zlib1g-dev -y | |
pip install --upgrade pip | |
pip install -r requirements/local.txt | |
- name: Configure environment | |
run: | | |
echo "JWKS_BASE64=$(python manage.py generate_jwks)" >> $GITHUB_ENV | |
- name: Run celery worker for tests | |
run: celery -A config.celery_app worker -B --loglevel=INFO --detach | |
- name: Run Tests with coverage | |
run: coverage run manage.py test --settings=config.settings.test | |
- name: Generate coverage report | |
run: | | |
coverage combine || true | |
coverage xml | |
coverage report -m | |
- name: Upload coverage report | |
uses: codecov/codecov-action@v2 | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
build-staging: | |
needs: test | |
name: Build & Push Staging to container registries | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }} | |
tags: | | |
type=raw,value=latest-${{ github.run_number }} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
flavor: | | |
latest=true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
build-production: | |
needs: test | |
name: Build & Push Production to container registries | |
if: github.ref == 'refs/heads/production' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }} | |
tags: | | |
type=raw,value=production-latest,enable=${{ github.ref == 'refs/heads/production' }} | |
type=raw,value=production-latest-${{ github.run_number }}-{{date 'YYYYMMDD'}}-{{sha}} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
flavor: | | |
latest=false | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
deploy-staging-egov: | |
needs: build-staging | |
name: Deploy to ECS API Egov | |
runs-on: ubuntu-latest | |
environment: | |
name: Staging-egov | |
url: https://careapi.ohc.network | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_DEFAULT_REGION }} | |
- name: IMAGE Tagging | |
env: | |
ECR_REGISTRY: ghcr.io/${{ github.repository }} | |
IMAGE_TAG: latest-${{ github.run_number }} | |
run: echo "IMAGE_VALUE=`echo ghcr.io/${{ github.repository }}:$IMAGE_TAG`" >> $GITHUB_ENV | |
- name: Fill Backend Api definition | |
id: task-def-api | |
uses: aws-actions/amazon-ecs-render-task-definition@v1 | |
with: | |
task-definition: ${{ env.ECS_TASK_DEFINITION_BACKEND }} | |
container-name: ${{ env.CONTAINER_NAME_BACKEND }} | |
image: ${{env.IMAGE_VALUE}} | |
- name: Deploy Backend Api | |
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
with: | |
task-definition: ${{ steps.task-def-api.outputs.task-definition }} | |
service: ${{ env.ECS_SERVICE_BACKEND }} | |
cluster: ${{ env.ECS_CLUSTER }} | |
wait-for-service-stability: true | |
- name: Fill Celery Cron definition | |
id: task-def-celery-cron | |
uses: aws-actions/amazon-ecs-render-task-definition@v1 | |
with: | |
task-definition: ${{ env.ECS_TASK_DEFINITION_CELERY }} | |
container-name: ${{ env.CONTAINER_NAME_CRON }} | |
image: ${{env.IMAGE_VALUE}} | |
- name: Fill Celery Worker definition | |
id: task-def-celery-worker | |
uses: aws-actions/amazon-ecs-render-task-definition@v1 | |
with: | |
task-definition: ${{ steps.task-def-celery-cron.outputs.task-definition }} | |
container-name: ${{ env.CONTAINER_NAME_WORKER }} | |
image: ${{env.IMAGE_VALUE}} | |
- name: Deploy Backend Celery | |
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
with: | |
task-definition: ${{ steps.task-def-celery-worker.outputs.task-definition }} | |
service: ${{ env.ECS_SERVICE_CELERY }} | |
cluster: ${{ env.ECS_CLUSTER }} | |
wait-for-service-stability: true | |
deploy-production-manipur: | |
needs: build-production | |
name: Deploy to GKE Manipur | |
runs-on: ubuntu-latest | |
environment: | |
name: Production-Manipur | |
url: https://careapi.mn.gov.in | |
steps: | |
- name: Checkout Kube Config | |
uses: actions/checkout@v3 | |
with: | |
repository: coronasafe/mn-care-infra | |
token: ${{ secrets.GIT_ACCESS_TOKEN }} | |
path: kube | |
ref: main | |
# Setup gcloud CLI | |
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 | |
with: | |
service_account_key: ${{ secrets.GKE_SA_KEY }} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
# Get the GKE credentials so we can deploy to the cluster | |
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e | |
with: | |
cluster_name: ${{ secrets.GKE_CLUSTER }} | |
location: ${{ secrets.GKE_ZONE }} | |
credentials: ${{ secrets.GKE_SA_KEY }} | |
- name: install kubectl | |
uses: azure/[email protected] | |
with: | |
version: "v1.23.6" | |
id: install | |
- name: Deploy Care Production Manipur | |
run: | | |
mkdir -p $HOME/.kube/ | |
cd kube/deployments/ | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-backend.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-beat.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-worker.yaml | |
kubectl apply -f care-backend.yaml | |
kubectl apply -f care-celery-beat.yaml | |
kubectl apply -f care-celery-worker.yaml | |
deploy-production-karnataka: | |
needs: build-production | |
name: Deploy to GKE Karnataka | |
runs-on: ubuntu-latest | |
environment: | |
name: Production-Karnataka | |
url: https://careapi.karnataka.care | |
steps: | |
- name: Checkout Kube Config | |
uses: actions/checkout@v3 | |
with: | |
repository: coronasafe/ka-care-infra | |
token: ${{ secrets.GIT_ACCESS_TOKEN }} | |
path: kube | |
ref: main | |
# Setup gcloud CLI | |
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 | |
with: | |
service_account_key: ${{ secrets.GKE_SA_KEY }} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
# Get the GKE credentials so we can deploy to the cluster | |
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e | |
with: | |
cluster_name: ${{ secrets.GKE_CLUSTER }} | |
location: ${{ secrets.GKE_ZONE }} | |
credentials: ${{ secrets.GKE_SA_KEY }} | |
- name: install kubectl | |
uses: azure/[email protected] | |
with: | |
version: "v1.23.6" | |
id: install | |
- name: Deploy Care Production Karnataka | |
run: | | |
mkdir -p $HOME/.kube/ | |
cd kube/deployments/ | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-backend.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-beat.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-worker.yaml | |
kubectl apply -f care-backend.yaml | |
kubectl apply -f care-celery-beat.yaml | |
kubectl apply -f care-celery-worker.yaml | |
deploy-production-assam: | |
needs: build-production | |
name: Deploy to GKE Assam | |
runs-on: ubuntu-latest | |
environment: | |
name: Production-Assam | |
url: https://careapi.assam.gov.in | |
steps: | |
- name: Checkout Kube Config | |
uses: actions/checkout@v3 | |
with: | |
repository: coronasafe/as-care-infra | |
token: ${{ secrets.GIT_ACCESS_TOKEN }} | |
path: kube | |
ref: main | |
# Setup gcloud CLI | |
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 | |
with: | |
service_account_key: ${{ secrets.GKE_SA_KEY }} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
# Get the GKE credentials so we can deploy to the cluster | |
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e | |
with: | |
cluster_name: ${{ secrets.GKE_CLUSTER }} | |
location: ${{ secrets.GKE_ZONE }} | |
credentials: ${{ secrets.GKE_SA_KEY }} | |
- name: install kubectl | |
uses: azure/[email protected] | |
with: | |
version: "v1.23.6" | |
id: install | |
- name: Deploy Care Production Assam | |
run: | | |
mkdir -p $HOME/.kube/ | |
cd kube/deployments/ | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-backend.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-beat.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-worker.yaml | |
kubectl apply -f care-backend.yaml | |
kubectl apply -f care-celery-beat.yaml | |
kubectl apply -f care-celery-worker.yaml | |
deploy-production-sikkim: | |
needs: build-production | |
name: Deploy to GKE Sikkim | |
runs-on: ubuntu-latest | |
environment: | |
name: Production-Sikkim | |
url: https://careapi.sikkim.gov.in | |
steps: | |
- name: Checkout Kube Config | |
uses: actions/checkout@v3 | |
with: | |
repository: coronasafe/sk-care-infra | |
token: ${{ secrets.GIT_ACCESS_TOKEN }} | |
path: kube | |
ref: main | |
# Setup gcloud CLI | |
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 | |
with: | |
service_account_key: ${{ secrets.GKE_SA_KEY }} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
# Get the GKE credentials so we can deploy to the cluster | |
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e | |
with: | |
cluster_name: ${{ secrets.GKE_CLUSTER }} | |
location: ${{ secrets.GKE_ZONE }} | |
credentials: ${{ secrets.GKE_SA_KEY }} | |
- name: install kubectl | |
uses: azure/[email protected] | |
with: | |
version: "v1.23.6" | |
id: install | |
- name: Deploy Care Production Sikkim | |
run: | | |
mkdir -p $HOME/.kube/ | |
cd kube/deployments/ | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-backend.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-beat.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-worker.yaml | |
kubectl apply -f care-backend.yaml | |
kubectl apply -f care-celery-beat.yaml | |
kubectl apply -f care-celery-worker.yaml | |
deploy-production-nagaland: | |
needs: build-production | |
name: Deploy to GKE Nagaland | |
runs-on: ubuntu-latest | |
environment: | |
name: Production - Nagaland | |
url: https://careapi.nagaland.gov.in | |
steps: | |
- name: Checkout Kube Config | |
uses: actions/checkout@v3 | |
with: | |
repository: coronasafe/nl-care-infra | |
token: ${{ secrets.GIT_ACCESS_TOKEN }} | |
path: kube | |
ref: main | |
# Setup gcloud CLI | |
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 | |
with: | |
service_account_key: ${{ secrets.GKE_SA_KEY }} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
# Get the GKE credentials, so we can deploy to the cluster | |
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e | |
with: | |
cluster_name: ${{ secrets.GKE_CLUSTER }} | |
location: ${{ secrets.GKE_ZONE }} | |
credentials: ${{ secrets.GKE_SA_KEY }} | |
- name: install kubectl | |
uses: azure/[email protected] | |
with: | |
version: "v1.23.6" | |
id: install | |
- name: Deploy Care Production Nagaland | |
run: | | |
mkdir -p $HOME/.kube/ | |
cd kube/deployments/ | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-backend.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-beat.yaml | |
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-worker.yaml | |
kubectl apply -f care-backend.yaml | |
kubectl apply -f care-celery-beat.yaml | |
kubectl apply -f care-celery-worker.yaml |