Skip to content

Commit

Permalink
Merge branch 'next' into feat/excel-image-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik authored Jul 4, 2024
2 parents 94203a4 + bf6bfd1 commit 49223af
Show file tree
Hide file tree
Showing 58 changed files with 14,458 additions and 4,856 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
echo $GH_PASSWORD | docker login ghcr.io -u $GH_ACTOR --password-stdin
docker build -t ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG -f apps/api/Dockerfile .
docker tag ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:latest
docker tag ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
# docker tag ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
docker run --network=host --name api -dit --env NODE_ENV=test --env JWT_SECRET=impler --env COOKIE_DOMAIN=impler ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG
docker run --network=host appropriate/curl --retry 10 --retry-delay 5 --retry-connrefused http://localhost:3000/v1/health-check | grep 'ok'
docker push ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
# docker push ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
docker push ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:latest
docker push ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG
echo "::set-output name=IMAGE::ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG"
# docker push ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG
# echo "::set-output name=IMAGE::ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$IMAGE_TAG"
86 changes: 86 additions & 0 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy Impler to Production

on:
push:
branches:
- main

jobs:
build_api:
permissions:
contents: read
packages: write
deployments: write
uses: ./.github/workflows/build-api.yml
secrets: inherit

build_embed:
permissions:
contents: read
packages: write
deployments: write
uses: ./.github/workflows/build-embed.yml
secrets: inherit

build_queuemanager:
permissions:
contents: read
packages: write
deployments: write
uses: ./.github/workflows/build-queuemanager.yml
secrets: inherit

build_web:
permissions:
contents: read
packages: write
deployments: write
uses: ./.github/workflows/build-web.yml
secrets: inherit

build_widget:
permissions:
contents: read
packages: write
deployments: write
uses: ./.github/workflows/build-widget.yml
secrets: inherit

tag_images:
permissions:
contents: read
packages: write
deployments: write
uses: ./.github/workflows/tag-images.yml
secrets: inherit

publish_npm:
permissions:
contents: read
packages: write
deployments: write
uses: ./.github/workflows/publish-prod-packages.yml
secrets: inherit

deploy_with_ssh:
runs-on: ubuntu-latest
needs:
- build_api
- build_embed
- build_queuemanager
- build_web
- build_widget
- tag_images
- publish_npm
if: |
always() &&
(needs.build_api.result == 'success' && needs.build_embed.result == 'success' && needs.build_queuemanager.result == 'success' && needs.build_web.result == 'success' && needs.build_widget.result == 'success' && needs.tag_images.result == 'success' && needs.publish_npm.result == 'success')
steps:
- name: Set up SSH and Run Docker Compose Up
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_QA }}
- name: Run Docker Compose Up
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME_QA }}@${{ secrets.SSH_HOST_QA }} \
"cd ${{ secrets.SSH_PATH_QA }} && docker compose up --pull always -d"
21 changes: 11 additions & 10 deletions .github/workflows/deploy-quality.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Deploy Impler to Quality

on:
push:
branches:
- next
pull_request:
branches: [next]
types:
- closed

jobs:
build_api:
permissions:
contents: read
packages: write
deployments: write
if: ${{ github.event_name == 'push' && (github.event.head_commit.modified || github.event.head_commit.added || github.event.head_commit.removed) && contains(toJSON(github.event.head_commit.modified), 'apps/api/') }}
if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'impler/api')) }}
uses: ./.github/workflows/build-api.yml
secrets: inherit

Expand All @@ -20,7 +21,7 @@ jobs:
contents: read
packages: write
deployments: write
if: ${{ github.event_name == 'push' && (github.event.head_commit.modified || github.event.head_commit.added || github.event.head_commit.removed) && contains(toJSON(github.event.head_commit.modified), 'apps/demo/') }}
if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'impler/embed')) }}
uses: ./.github/workflows/build-embed.yml
secrets: inherit

Expand All @@ -29,7 +30,7 @@ jobs:
contents: read
packages: write
deployments: write
if: ${{ github.event_name == 'push' && (github.event.head_commit.modified || github.event.head_commit.added || github.event.head_commit.removed) && contains(toJSON(github.event.head_commit.modified), 'apps/queue-manager/') }}
if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'impler/queuemanager')) }}
uses: ./.github/workflows/build-queuemanager.yml
secrets: inherit

Expand All @@ -38,7 +39,7 @@ jobs:
contents: read
packages: write
deployments: write
if: ${{ github.event_name == 'push' && (github.event.head_commit.modified || github.event.head_commit.added || github.event.head_commit.removed) && contains(toJSON(github.event.head_commit.modified), 'apps/web/') }}
if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'impler/web')) }}
uses: ./.github/workflows/build-web.yml
secrets: inherit

Expand All @@ -47,7 +48,7 @@ jobs:
contents: read
packages: write
deployments: write
if: ${{ github.event_name == 'push' && (github.event.head_commit.modified || github.event.head_commit.added || github.event.head_commit.removed) && contains(toJSON(github.event.head_commit.modified), 'apps/widget/') }}
if: ${{ (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'impler/widget')) }}
uses: ./.github/workflows/build-widget.yml
secrets: inherit

Expand All @@ -63,11 +64,11 @@ jobs:
always() &&
(needs.build_api.result == 'success' || needs.build_embed.result == 'success' || needs.build_queuemanager.result == 'success' || needs.build_web.result == 'success' || needs.build_widget.result == 'success')
steps:
- name: Set up SSH and Run Docker Compose Up
- name: Set up SSH and Up the service
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_QA }}
- name: Run Docker Compose Up
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME_QA }}@${{ secrets.SSH_HOST_QA }} \
"cd ${{ secrets.SSH_PATH_QA }} && docker compose up -d"
"cd ${{ secrets.SSH_PATH_QA }} && sudo docker compose up --pull always -d"
7 changes: 1 addition & 6 deletions .github/workflows/publish-prod-packages.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
name: Publish Packages to NPM Registry

on:
push:
tags:
- '**@impler/react@**'
- '**@impler/shared@**'
workflow_dispatch:
workflow_call:

jobs:
publish_prod_react:
if: "!contains(github.event.head_commit.message, 'ci skip')"
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 80
environment: Production
permissions:
contents: read
packages: write
Expand Down
28 changes: 16 additions & 12 deletions .github/workflows/tag-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ name: Tag Docker Version
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
inputs:
version:
description: 'The version to tag docker images'
workflow_call:
secrets:
GH_PACKAGES:
required: true
type: string

jobs:
tag_images:
runs-on: ubuntu-latest
timeout-minutes: 80
environment: Production
permissions:
contents: read
packages: write
Expand All @@ -26,12 +23,19 @@ jobs:
GH_PASSWORD: ${{ secrets.GH_PACKAGES }}
run: |
echo $GH_PASSWORD | docker login ghcr.io -u $GH_ACTOR --password-stdin
- name: Get Latest Docker Version
run: | # Multi-line command definition
#!/bin/bash
# (Your script content from previous response)
version=$(curl -sSL https://api.github.com/repos/implerhq/impler.io/releases/latest | jq -r '.tag_name' | grep -oP 'v\K\d+(?:\.\d+){2}')
echo "DOCKER_VERSION=$version" >> $GITHUB_ENV # Add to environment variables
- name: Tag API
env:
REGISTERY_OWNER: implerhq
DOCKER_NAME: impler/api
DOCKER_VERSION: ${{ inputs.version }}
DOCKER_VERSION: ${{ env.DOCKER_VERSION }}
run: |
docker pull ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
docker tag ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$DOCKER_VERSION
Expand All @@ -42,7 +46,7 @@ jobs:
env:
REGISTERY_OWNER: implerhq
DOCKER_NAME: impler/queue-manager
DOCKER_VERSION: ${{ inputs.version }}
DOCKER_VERSION: ${{ env.DOCKER_VERSION }}
run: |
docker pull ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
docker tag ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$DOCKER_VERSION
Expand All @@ -53,7 +57,7 @@ jobs:
env:
REGISTERY_OWNER: implerhq
DOCKER_NAME: impler/embed
DOCKER_VERSION: ${{ inputs.version }}
DOCKER_VERSION: ${{ env.DOCKER_VERSION }}
run: |
docker pull ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
docker tag ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$DOCKER_VERSION
Expand All @@ -64,7 +68,7 @@ jobs:
env:
REGISTERY_OWNER: implerhq
DOCKER_NAME: impler/widget
DOCKER_VERSION: ${{ inputs.version }}
DOCKER_VERSION: ${{ env.DOCKER_VERSION }}
run: |
docker pull ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
docker tag ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$DOCKER_VERSION
Expand All @@ -75,7 +79,7 @@ jobs:
env:
REGISTERY_OWNER: implerhq
DOCKER_NAME: impler/web
DOCKER_VERSION: ${{ inputs.version }}
DOCKER_VERSION: ${{ env.DOCKER_VERSION }}
run: |
docker pull ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod
docker tag ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:prod ghcr.io/$REGISTERY_OWNER/$DOCKER_NAME:$DOCKER_VERSION
Expand Down
6 changes: 3 additions & 3 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/api",
"version": "0.20.0",
"version": "0.20.1",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand All @@ -21,8 +21,8 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.185.0",
"@aws-sdk/client-ses": "^3.354.0",
"@impler/dal": "^0.20.0",
"@impler/shared": "^0.20.0",
"@impler/dal": "^0.20.1",
"@impler/shared": "^0.20.1",
"@nestjs/common": "^9.1.2",
"@nestjs/core": "^9.1.2",
"@nestjs/jwt": "^10.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { PaymentAPIService } from '@impler/shared';
import { BadRequestException, Injectable, InternalServerErrorException } from '@nestjs/common';

@Injectable()
export class ApplyCoupon {
constructor(private paymentApiService: PaymentAPIService) {}

async execute(couponCode: string, userEmail: string, planCode: string) {
try {
return await this.paymentApiService.checkAppliedCoupon(couponCode, userEmail, planCode);
} catch (error) {
if (error) {
throw new BadRequestException(error);
} else throw new InternalServerErrorException();
}
}
}
26 changes: 26 additions & 0 deletions apps/api/src/app/user/usecases/checkout/checkout.usecase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { PaymentAPIService } from '@impler/shared';
import { Injectable } from '@nestjs/common';

@Injectable()
export class Checkout {
constructor(private paymentApiService: PaymentAPIService) {}

async execute({
externalId,
paymentMethodId,
planCode,
couponCode,
}: {
externalId: string;
planCode: string;
paymentMethodId: string;
couponCode?: string;
}) {
return this.paymentApiService.checkout({
externalId: externalId,
planCode: planCode,
paymentMethodId: paymentMethodId,
couponCode: couponCode,
});
}
}
6 changes: 6 additions & 0 deletions apps/api/src/app/user/usecases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { ConfirmIntentId } from './save-payment-intent-id/save-paymentintentid.u
import { RetrievePaymentMethods } from './retrive-payment-methods/retrive-payment-methods.usecase';
import { DeleteUserPaymentMethod } from './delete-user-payment-method/delete-user-payment-method.usecase';
import { GetTransactionHistory } from './get-transaction-history/get-transaction-history.usecase';
import { ApplyCoupon } from './apply-coupon/apply-coupon.usecase';
import { Checkout } from './checkout/checkout.usecase';

export const USE_CASES = [
GetImportCounts,
Expand All @@ -16,6 +18,8 @@ export const USE_CASES = [
RetrievePaymentMethods,
DeleteUserPaymentMethod,
GetTransactionHistory,
ApplyCoupon,
Checkout,
//
];

Expand All @@ -28,4 +32,6 @@ export {
RetrievePaymentMethods,
DeleteUserPaymentMethod,
GetTransactionHistory,
ApplyCoupon,
Checkout,
};
Loading

0 comments on commit 49223af

Please sign in to comment.