diff --git a/.drone.yml b/.drone.yml index 6397fe22..c86168c5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,9 +15,27 @@ trigger: - refs/heads/master steps: - - name: deploy script + - name: npm-install image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: + - apk add --no-cache make + - npm install --legacy-peer-deps + + - name: make-prod + image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: + - make prod + depends_on: + - npm-install + - name: deploy script + image: amazon/aws-cli:latest environment: AWS_ACCESS_KEY_ID: from_secret: AWS_ACCESS_KEY_ID @@ -25,27 +43,126 @@ steps: from_secret: AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION: from_secret: AWS_DEFAULT_REGION - REACT_APP_STRIPE_PK: - from_secret: REACT_APP_STRIPE_PK - SSH_KEY_AUTH: - from_secret: SSH_KEY_AUTH - commands: - - apk add --no-cache aws-cli bash git openssh-client make rsync - - npm install --legacy-peer-deps - - make prod # - aws s3 sync build s3://insports-prod --delete # - aws cloudfront create-invalidation --distribution-id E3KY6BCU3AYHEW --paths "/*" - aws s3 sync build s3://instat-frontend-test-a --delete - aws cloudfront create-invalidation --distribution-id E1WZHVCHZ48SG6 --paths "/*" + depends_on: + - make-prod + + - name: make-auth + image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: - make auth-production-build + depends_on: + - npm-install + + - name: deploy-S3-auth + image: amazon/aws-cli:latest + environment: + AWS_ACCESS_KEY_ID: + from_secret: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: AWS_SECRET_ACCESS_KEY + AWS_DEFAULT_REGION: + from_secret: AWS_DEFAULT_REGION + commands: + - aws s3 sync build s3://insports-auth --delete + - aws cloudfront create-invalidation --distribution-id EERIKX9X2SRPJ --paths "/*" + depends_on: + - make-auth + + - name: deploy-old-auth-server + image: node:16-alpine + environment: + SSH_KEY_AUTH: + from_secret: SSH_KEY_AUTH + commands: + - apk add --no-cache openssh-client rsync - eval $(ssh-agent -s) - echo -n "$SSH_KEY_AUTH" | tr -d '\r' | ssh-add - - mkdir -p ~/.ssh && chmod 700 ~/.ssh - - ssh-keyscan auth.insports.tv >> ~/.ssh/known_hosts - - rsync -v -r -C build_auth/ ubuntu@auth.insports.tv:/home/ubuntu/ott-auth/src/frontend/ - - rsync -v -r -C build_auth/clients/* ubuntu@auth.insports.tv:/home/ubuntu/ott-auth/src/frontend/templates - - ssh ubuntu@auth.insports.tv 'bash -s' < ./run.sh OTT-2535 docker-compose-stage.yaml + depends_on: + - make-auth + + - name: make-india + image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: + - make india-build + depends_on: + - npm-install + + - name: deploy-india + image: amazon/aws-cli:latest + environment: + AWS_ACCESS_KEY_ID: + from_secret: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: AWS_SECRET_ACCESS_KEY + AWS_DEFAULT_REGION: + from_secret: AWS_DEFAULT_REGION + commands: + - aws s3 sync build_india s3://insports-india --delete + - aws cloudfront create-invalidation --distribution-id E5DKN8IPOMASO --paths "/*" + depends_on: + - make-india + + - name: make-facr + image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: + - make facr-build + depends_on: + - npm-install + + - name: deploy-facr + image: amazon/aws-cli:latest + environment: + AWS_ACCESS_KEY_ID: + from_secret: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: AWS_SECRET_ACCESS_KEY + AWS_DEFAULT_REGION: + from_secret: AWS_DEFAULT_REGION + commands: + - aws s3 sync build_facr s3://insports-facr-tv --delete + - aws cloudfront create-invalidation --distribution-id E1ZYJS9RAJO89D --paths "/*" + depends_on: + - make-facr + + - name: make-lff + image: node:16-alpine + environment: + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK + commands: + - make lff-build + depends_on: + - npm-install + + - name: deploy-lff + image: amazon/aws-cli:latest + environment: + AWS_ACCESS_KEY_ID: + from_secret: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: AWS_SECRET_ACCESS_KEY + AWS_DEFAULT_REGION: + from_secret: AWS_DEFAULT_REGION + commands: + - aws s3 sync build_lff s3://insports-tv-lff-lv --delete + - aws cloudfront create-invalidation --distribution-id E2127IDW4TEH4S --paths "/*" + depends_on: + - make-lff --- kind: pipeline @@ -131,7 +248,6 @@ steps: ## - ssh-keyscan auth.insports.tv >> ~/.ssh/known_hosts ## - rsync -v -r -C build_auth/ ubuntu@auth.insports.tv:/home/ubuntu/ott-auth/src/frontend/ ## - rsync -v -r -C build_auth/clients/* ubuntu@auth.insports.tv:/home/ubuntu/ott-auth/src/frontend/templates -## - ssh ubuntu@auth.insports.tv 'bash -s' < ./run.sh OTT-2535 docker-compose-stage.yaml --- @@ -536,4 +652,5 @@ steps: - ssh-keyscan auth.test.insports.tv >> ~/.ssh/known_hosts - rsync -v -r -C build_auth/ ubuntu@auth.test.insports.tv:/home/ubuntu/ott-auth/src/frontend/ - rsync -v -r -C build_auth/clients/* ubuntu@auth.test.insports.tv:/home/ubuntu/ott-auth/src/frontend/templates - - ssh ubuntu@auth.test.insports.tv 'bash -s' < ./run.sh OTT-2535-test docker-compose-test.yaml + - aws s3 sync build s3://auth-insports-test --delete + - aws cloudfront create-invalidation --distribution-id E10YI3RFOZZDLZ --paths "/*" diff --git a/Makefile b/Makefile index 293df69c..52d17c36 100644 --- a/Makefile +++ b/Makefile @@ -120,14 +120,24 @@ auth-production-build: facr-build: clean REACT_APP_TYPE=ott \ - REACT_APP_ENV=staging \ - REACT_APP_CLIENT=facr \ + REACT_APP_ENV=production \ + REACT_APP_STRIPE_PK=pk_live_51J5TEYEDSxVnTgDW7v2lF8GGogrm7XaaICZ9CN876sITIBBauZgB2ommUTUOiY868jzpbhQjZcoBOjIRX5Vs54Aq00y4C3USyB \ + BUILD_PATH=build_facr \ + npm run build + +india-build: clean + REACT_APP_TYPE=ott \ + REACT_APP_ENV=production \ + REACT_APP_STRIPE_PK=pk_live_51J5TEYEDSxVnTgDW7v2lF8GGogrm7XaaICZ9CN876sITIBBauZgB2ommUTUOiY868jzpbhQjZcoBOjIRX5Vs54Aq00y4C3USyB \ + BUILD_PATH=build_india \ npm run build lff-build: clean REACT_APP_TYPE=ott \ - REACT_APP_ENV=staging \ + REACT_APP_ENV=production \ + REACT_APP_STRIPE_PK=pk_live_51J5TEYEDSxVnTgDW7v2lF8GGogrm7XaaICZ9CN876sITIBBauZgB2ommUTUOiY868jzpbhQjZcoBOjIRX5Vs54Aq00y4C3USyB \ REACT_APP_CLIENT=lff \ + BUILD_PATH=build_lff \ npm run build .PHONY: build @@ -151,6 +161,13 @@ preprod: clean REACT_APP_STRIPE_PK=pk_live_ANI76cBhSo69DZUxPmyRVIZW \ npm run build +india-prod: clean + REACT_APP_TYPE=ott \ + REACT_APP_ENV=production \ + REACT_APP_CLIENT=india \ + REACT_APP_STRIPE_PK=pk_live_51J5TEYEDSxVnTgDW7v2lF8GGogrm7XaaICZ9CN876sITIBBauZgB2ommUTUOiY868jzpbhQjZcoBOjIRX5Vs54Aq00y4C3USyB \ + npm run build && cp -r .well-known build + facr-prod: clean REACT_APP_TYPE=ott \ REACT_APP_ENV=production \ @@ -175,36 +192,6 @@ lff-prod: clean deploy-all: prod preprod facr-prod lff-prod -stage: build-stage - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/wwwroot/ - -a-stage: build-a - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/a-wwwroot/ - -b-stage: build-b - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/b-wwwroot/ - -c-stage: build-c - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/c-wwwroot/ - -d-stage: build-d - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/d-wwwroot/ - -e-stage: build-e - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/e-wwwroot/ - -f-stage: build-f - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/f-wwwroot/ - -g-stage: build-g - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/g-wwwroot/ - -h-stage: build-h - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/h-wwwroot/ - -i-stage: build-i - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/i-wwwroot/ - test: npm test diff --git a/package.json b/package.json index 2bcac2b3..8c4c954d 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "test:auth": "REACT_APP_TYPE=auth-service react-scripts test", "facr": "REACT_APP_CLIENT=facr react-scripts start", "lff": "REACT_APP_CLIENT=lff react-scripts start", + "india": "REACT_APP_CLIENT=india react-scripts start", "insports": "REACT_APP_CLIENT=insports react-scripts start" }, "dependencies": { diff --git a/run.sh b/run.sh deleted file mode 100644 index 6b88230f..00000000 --- a/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -branch=$1 -composefile=$2 - -cd /home/ubuntu/ott-auth -docker-compose -f $composefile down -docker-compose -f $composefile up -d -echo "[>] Deployment done." diff --git a/src/config/clients/index.tsx b/src/config/clients/index.tsx index 72ddd498..aef4ea7d 100644 --- a/src/config/clients/index.tsx +++ b/src/config/clients/index.tsx @@ -4,6 +4,7 @@ import { facr } from './facr' import { instat } from './instat' import { lff } from './lff' import { insports } from './insports' +import { india } from './india' export const currentClient = process.env.REACT_APP_CLIENT || 'insports' @@ -11,9 +12,11 @@ export const isLffClient = currentClient === 'lff' export const isInSportsClient = currentClient === 'insports' export const isInstatClient = currentClient === 'instat' export const isFacrClient = currentClient === 'facr' +export const isIndiaClient = currentClient === 'india' const clients = { facr, + india, insports, instat, lff, diff --git a/src/config/clients/india.tsx b/src/config/clients/india.tsx new file mode 100644 index 00000000..461adbac --- /dev/null +++ b/src/config/clients/india.tsx @@ -0,0 +1,15 @@ +import { + ClientConfig, + ClientIds, + ClientNames, +} from './types' + +import { insports } from './insports' + +export const india: ClientConfig = { + ...insports, + auth: { + clientId: ClientIds.India, + }, + name: ClientNames.India, +} diff --git a/src/config/clients/types.tsx b/src/config/clients/types.tsx index 9cdaca4f..7f45e754 100644 --- a/src/config/clients/types.tsx +++ b/src/config/clients/types.tsx @@ -6,6 +6,7 @@ type StyledCss = ReturnType export enum ClientIds { Facr = 'facr-ott-web', + India = 'india-ott-web', Insports = 'insports-ott-web', Instat = 'ott-web', Lff = 'lff-ott-web', @@ -13,6 +14,7 @@ export enum ClientIds { export enum ClientNames { Facr = 'facr', + India = 'india', Insports = 'insports', Instat = 'instat', Lff = 'lff', diff --git a/src/config/routes.tsx b/src/config/routes.tsx index 8a397573..b307e805 100644 --- a/src/config/routes.tsx +++ b/src/config/routes.tsx @@ -5,15 +5,15 @@ import { ENV, isProduction } from './env' export const APIS = { preproduction: { api: 'https://api.insports.tv', - auth: 'https://api.auth.insports.tv', + auth: 'https://auth.insports.tv', }, production: { api: 'https://api.insports.tv', - auth: 'https://api.auth.insports.tv', + auth: 'https://auth.insports.tv', }, staging: { api: 'https://api.test.insports.tv', - auth: 'https://api.auth.test.insports.tv', + auth: 'https://auth.test.insports.tv', }, } diff --git a/src/features/AuthServiceApp/config/clients/index.tsx b/src/features/AuthServiceApp/config/clients/index.tsx index b1401617..040a93d5 100644 --- a/src/features/AuthServiceApp/config/clients/index.tsx +++ b/src/features/AuthServiceApp/config/clients/index.tsx @@ -4,12 +4,14 @@ import { facr } from './facr' import { insports } from './insports' import { instat } from './instat' import { lff } from './lff' +import { india } from './india' const clients = { [ClientIds.Facr]: facr, [ClientIds.Instat]: instat, [ClientIds.Lff]: lff, [ClientIds.Insports]: insports, + [ClientIds.India]: india, } const params = new URLSearchParams(window.location.search) diff --git a/src/features/AuthServiceApp/config/clients/india.tsx b/src/features/AuthServiceApp/config/clients/india.tsx new file mode 100644 index 00000000..e7e1c99e --- /dev/null +++ b/src/features/AuthServiceApp/config/clients/india.tsx @@ -0,0 +1,9 @@ +import { insports as platformInsports } from 'config/clients/insports' + +import type { ClientConfig } from './types' +import { insports } from './insports' + +export const india: ClientConfig = { + ...platformInsports, + ...insports, +} diff --git a/src/features/AuthStore/helpers.tsx b/src/features/AuthStore/helpers.tsx index 7f8662a1..2faf2926 100644 --- a/src/features/AuthStore/helpers.tsx +++ b/src/features/AuthStore/helpers.tsx @@ -23,6 +23,8 @@ export const getClientNameByRedirectUri = () => { switch (client.name) { case ClientNames.Lff: return 'lff.instat' + case ClientNames.India: + return 'india.insports' case ClientNames.Facr: return ClientNames.Facr case ClientNames.Instat: @@ -35,7 +37,12 @@ export const getClientNameByRedirectUri = () => { const redirectUrl = () => { const clientName = getClientNameByRedirectUri() switch (true) { - case (process.env.NODE_ENV === 'development' || client.name === 'lff' || client.name === 'facr'): + case ( + process.env.NODE_ENV === 'development' + || client.name === 'lff' + || client.name === 'facr' + || client.name === 'india' + ): return `${window.origin}/redirect` case (ENV === 'staging' || ENV === 'preproduction'): return `https://${stageENV}.insports.tv/redirect` diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 65952d05..56a364a5 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -3,7 +3,7 @@ declare namespace NodeJS { export interface ProcessEnv { - REACT_APP_CLIENT: 'instat' | 'facr' | 'lff' | 'insports', + REACT_APP_CLIENT: 'instat' | 'facr' | 'lff' | 'insports' | 'india', REACT_APP_ENV: 'production' | 'preproduction' | 'staging', REACT_APP_STAGE: 'staging' | 'test-a' | 'test-b' | 'test-c' | 'test-d' | 'test-e' | 'test-f' | 'test-g' | 'test-h' | 'test-i' | 'test-j' | 'test', REACT_APP_TYPE: 'auth-service' | 'ott',