Skip to content

Commit

Permalink
Merge pull request #7432 from coronasafe/staging
Browse files Browse the repository at this point in the history
Production release v24.12.0 | March week 3
  • Loading branch information
gigincg authored Mar 18, 2024
2 parents 0635b06 + 1b45ac6 commit a7875df
Show file tree
Hide file tree
Showing 17 changed files with 462 additions and 377 deletions.
152 changes: 56 additions & 96 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ on:
push:
branches:
- develop
- master
- staging
tags:
- v*
pull_request:
branches:
- develop
- master
- staging
workflow_dispatch:

concurrency:
Expand All @@ -29,25 +31,26 @@ jobs:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }}
key: ${{ runner.os }}-buildx-test-${{ hashFiles('package-lock.json', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-buildx-test-
- name: Test build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: false
provenance: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

Expand All @@ -60,132 +63,89 @@ jobs:
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-staging:
build:
needs: test
name: Build & Push Staging to container registries
if: github.ref == 'refs/heads/develop'
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/staging' || github.ref == 'refs/tags/v*'
name: Build & Push to container registries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Docker meta
- name: Generate docker tags
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }}
tags: |
type=raw,value=production-latest,enable=${{ github.ref == 'refs/heads/v*' }}
type=raw,value=production-latest-${{ github.run_number }}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.ref == 'refs/heads/v*' }}
type=raw,value=staging-latest,enable=${{ github.ref == 'refs/heads/staging' }}
type=raw,value=staging-latest-${{ github.run_number }}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.ref == 'refs/heads/staging' }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/develop' }}
type=raw,value=latest-${{ github.run_number }}-{{date 'YYYYMMDD'}}-{{sha}}
type=raw,value=latest-${{ github.run_number }},enable=${{ github.ref == 'refs/heads/develop' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=true
latest=false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
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/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_owner }}/${{ env.IMAGE_NAME }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=production-latest,enable=${{ github.ref == 'refs/heads/master' }}
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@v3
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }}
key: ${{ runner.os }}-buildx-build-${{ hashFiles('package-lock.json', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-buildx-build-
- 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
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
provenance: false
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
notify-release:
needs: build
if: github.ref == 'refs/tags/v*'
name: Notify release
runs-on: ubuntu-latest
steps:
- name: Notify release
run: |
echo "Release ${{ github.sha }} is ready to be deployed to production"
deploy-staging-gcp:
needs: build-staging
needs: build
if: github.ref == 'refs/heads/staging'
name: Deploy to staging GCP cluster
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -231,7 +191,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-manipur:
needs: build-production
needs: notify-release
name: Deploy to GKE Manipur
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -277,7 +237,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-karnataka:
needs: build-production
needs: notify-release
name: Deploy to GKE Karnataka
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -323,7 +283,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-sikkim:
needs: build-production
needs: notify-release
name: Deploy to GKE Sikkim
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -369,7 +329,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-assam:
needs: build-production
needs: notify-release
name: Deploy to GKE Assam
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -415,7 +375,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-nagaland:
needs: build-production
needs: notify-release
name: Deploy to GKE Nagaland
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -461,7 +421,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-meghalaya:
needs: build-production
needs: notify-release
name: Deploy to GKE Meghalaya
runs-on: ubuntu-latest
environment:
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#build-stage
FROM node:18-buster-slim as build-stage
FROM --platform=$BUILDPLATFORM node:18-buster-slim as build-stage

WORKDIR /app

ENV NODE_OPTIONS="--max-old-space-size=4096"

RUN if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then apt-get update && apt-get install -y python3-dev make g++; fi

COPY package.json package-lock.json ./

RUN npm install --legacy-peer-deps
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/users_spec/user_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("User Homepage", () => {
userPage.typeInFirstName("Dev");
userPage.typeInLastName("Doctor");
userPage.selectRole("Doctor");
userPage.selectState("Kerala");
userPage.selectDistrict("Ernakulam");
userPage.typeInPhoneNumber(phone_number);
userPage.typeInAltPhoneNumber(alt_phone_number);
Expand Down
9 changes: 6 additions & 3 deletions cypress/pageobject/Users/UserSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class UserPage {
.and("include", "phone_number=%2B919876543219")
.and("include", "alt_phone_number=%2B919876543219")
.and("include", "user_type=Doctor")
.and("include", "district_id=7");
.and("include", "district=7");
}

checkUsernameText(username: string) {
Expand Down Expand Up @@ -62,9 +62,12 @@ export class UserPage {
cy.get("[role='option']").contains(role).click();
}

selectState(state: string) {
cy.searchAndSelectOption("#state input", state);
}

selectDistrict(district: string) {
cy.get("input[name='district']").click().type(district);
cy.get("[role='option']").contains(district).click();
cy.searchAndSelectOption("#district input", district);
}

typeInPhoneNumber(phone: string) {
Expand Down
16 changes: 12 additions & 4 deletions src/Common/hooks/useMSEplayer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useRef } from "react";
import axios from "axios";

export interface IAsset {
middlewareHostname: string;
Expand Down Expand Up @@ -45,9 +44,18 @@ const stopStream =
(payload: { id: string }, options: IOptions) => {
const { id } = payload;
ws?.close();
axios
.post(`https://${middlewareHostname}/stop`, {
id,
fetch(`https://${middlewareHostname}/stop`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ id }),
})
.then((res) => {
if (!res.ok) {
throw new Error("network response was not ok");
}
return res.json();
})
.then((res) => options?.onSuccess && options.onSuccess(res))
.catch((err) => options.onError && options.onError(err));
Expand Down
10 changes: 7 additions & 3 deletions src/Components/Assets/AssetType/ONVIFCamera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useState } from "react";
import { AssetData, ResolvedMiddleware } from "../AssetTypes";
import * as Notification from "../../../Utils/Notifications.js";
import { BedModel } from "../../Facility/models";
import axios from "axios";
import { getCameraConfig } from "../../../Utils/transformUtils";
import CameraConfigure from "../configure/CameraConfigure";
import Loading from "../../Common/Loading";
Expand Down Expand Up @@ -100,13 +99,18 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
};
try {
setLoadingAddPreset(true);
const presetData = await axios.get(

const response = await fetch(
`https://${resolvedMiddleware?.hostname}/status?hostname=${config.hostname}&port=${config.port}&username=${config.username}&password=${config.password}`
);
if (!response.ok) {
throw new Error("Network error");
}
const presetData = await response.json();

const { res } = await request(routes.createAssetBed, {
body: {
meta: { ...data, ...presetData.data },
meta: { ...data, ...presetData },
asset: assetId,
bed: bed?.id as string,
},
Expand Down
Loading

0 comments on commit a7875df

Please sign in to comment.