diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ba84f1e99..021110bd4 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -14,16 +14,16 @@ jobs: environment: production env: - DOCKER_HUB: ${{ secrets.DOCKER_HUB }} - APP_NAME: ${{ github.repository }} + DOCKER_HUB: ${{ secrets.DOCKER_HUB }} + APP_NAME: ${{ vars.APP_NAME_PRODUCTION }} APP_PORT: 3000 - APP_PORT_EXPOSE: ${{ secrets.APP_PORT }} + APP_PORT_EXPOSE: ${{ secrets.APP_PORT_PRODUCTION }} APP_NETWORK: app-network - SSH_HOST: ${{ secrets.SSH_HOST }} - SSH_PORT: ${{ secrets.SSH_PORT }} - SSH_USER: ${{ secrets.SSH_USER }} - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY}} + SSH_HOST: ${{ secrets.SSH_HOST_PRODUCTION }} + SSH_PORT: ${{ secrets.SSH_PORT_PRODUCTION }} + SSH_USER: ${{ secrets.SSH_USER_PRODUCTION }} + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_PRODUCTION}} steps: - name: Git checkout @@ -32,7 +32,7 @@ jobs: - name: Get short sha commit id: git run: | - echo "short_sha=$(git rev-parse --short $GITHUB_SHA)" >> "$GITHUB_OUTPUT" + echo "$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_OUTPUT" - name: Get latest version id: version @@ -40,7 +40,6 @@ jobs: - name: Git run: | - echo Branch name is: ${{ github.ref_name }} echo Short sha: ${{ steps.git.outputs.short_sha }} echo Version is: ${{ steps.version.outputs.current-version }} @@ -49,6 +48,7 @@ jobs: echo DOCKER_HUB is: ${{ env.DOCKER_HUB }} echo APP_NAME is: ${{ env.APP_NAME }} echo APP_PORT is: ${{ env.APP_PORT }} + echo APP_PORT_EXPOSE is: ${{ env.APP_PORT_EXPOSE }} echo APP_NETWORK is: ${{ env.APP_NETWORK }} - name: Set up QEMU @@ -67,12 +67,12 @@ jobs: docker run -itd \ --env NODE_ENV=production \ --hostname ${{ env.APP_NAME }} \ - --publish ${{ secrets.APP_PORT }}:${{ env.APP_PORT }} \ + --publish ${{ secrets.APP_PORT_EXPOSE }}:${{ env.APP_PORT }} \ --network ${{ env.APP_NETWORK }} \ --volume /app/${{ env.APP_NAME }}/logs/:/app/logs/ \ --volume /app/${{ env.APP_NAME }}/.env:/app/.env \ --restart unless-stopped \ - --name ${{ env.APP_NAME }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_HUB }}:main_v${{ steps.version.outputs.current-version }}_sha-${{ steps.git.outputs.short_sha }} + --name ${{ env.APP_NAME }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_HUB }}:main_v${{ steps.version.outputs.current-version }}_sha-${{ steps.git.outputs.short_sha }} host: ${{ secrets.SSH_HOST }} port: ${{ secrets.SSH_PORT }} user: ${{ secrets.SSH_USER }} @@ -98,16 +98,16 @@ jobs: environment: staging env: - DOCKER_HUB: ${{ secrets.DOCKER_HUB }} - APP_NAME: ${{ github.repository }} + DOCKER_HUB: ${{ secrets.DOCKER_HUB }} + APP_NAME: ${{ vars.APP_NAME_STAGING }} APP_PORT: 3000 - APP_PORT_EXPOSE: ${{ secrets.APP_PORT }} + APP_PORT_EXPOSE: ${{ secrets.APP_PORT_STAGING }} APP_NETWORK: app-network - SSH_HOST: ${{ secrets.SSH_HOST }} - SSH_PORT: ${{ secrets.SSH_PORT }} - SSH_USER: ${{ secrets.SSH_USER }} - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + SSH_HOST: ${{ secrets.SSH_HOST_STAGING }} + SSH_PORT: ${{ secrets.SSH_PORT_STAGING }} + SSH_USER: ${{ secrets.SSH_USER_STAGING }} + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_STAGING }} steps: - name: Git checkout @@ -124,7 +124,6 @@ jobs: - name: Git run: | - echo Branch name is: ${{ github.ref_name }} echo Short sha: ${{ steps.git.outputs.short_sha }} echo Version is: ${{ steps.version.outputs.current-version }} @@ -133,6 +132,7 @@ jobs: echo DOCKER_HUB is: ${{ env.DOCKER_HUB }} echo APP_NAME is: ${{ env.APP_NAME }} echo APP_PORT is: ${{ env.APP_PORT }} + echo APP_PORT_EXPOSE is: ${{ env.APP_PORT_EXPOSE }} echo APP_NETWORK is: ${{ env.APP_NETWORK }} - name: Set up QEMU @@ -156,7 +156,7 @@ jobs: --volume /app/${{ env.APP_NAME }}/logs/:/app/logs/ \ --volume /app/${{ env.APP_NAME }}/.env:/app/.env \ --restart unless-stopped \ - --name ${{ env.APP_NAME }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_HUB }}:staging_v${{ steps.version.outputs.current-version }}_sha-${{ steps.git.outputs.short_sha }} + --name ${{ env.APP_NAME }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_HUB }}:staging_v${{ steps.version.outputs.current-version }}_sha-${{ steps.git.outputs.short_sha }} host: ${{ env.SSH_HOST }} port: ${{ env.SSH_PORT }} user: ${{ env.SSH_USER }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d25fb7ac..2ea2b5088 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build against builder + - name: Build builder uses: docker/build-push-action@v4 with: builder: ${{ steps.builder.outputs.name }} @@ -73,7 +73,7 @@ jobs: with: builder: ${{ steps.main.outputs.name }} file: ${{ env.DOCKERFILE }} - args: | + build-args: | NODE_ENV=production target: main tags: | @@ -82,19 +82,16 @@ jobs: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_HUB }}:main_v${{ steps.version.outputs.current-version }}_sha-${{ steps.git.outputs.short_sha }} push: true - - name: Build main and push + - name: Build staging and push uses: docker/build-push-action@v4 if: ${{ github.ref_name == 'staging' }} with: builder: ${{ steps.main.outputs.name }} file: ${{ env.DOCKERFILE }} - args: | + build-args: | NODE_ENV=staging target: main tags: | ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_HUB }}:staging_v${{ steps.version.outputs.current-version }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_HUB }}:staging_v${{ steps.version.outputs.current-version }}_sha-${{ steps.git.outputs.short_sha }} push: true - - - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a31f76274..9902c7ecd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,9 +5,9 @@ permissions: on: - # push: - # branches: - # - main + push: + branches: + - main workflow_dispatch: jobs: diff --git a/src/common/error/filters/error.http.filter.ts b/src/common/error/filters/error.http.filter.ts index 2378fe8e0..d1d18f7a3 100644 --- a/src/common/error/filters/error.http.filter.ts +++ b/src/common/error/filters/error.http.filter.ts @@ -5,6 +5,7 @@ import { HttpException, HttpStatus, Optional, + InternalServerErrorException, } from '@nestjs/common'; import { HttpArgumentsHost } from '@nestjs/common/interfaces'; import { ConfigService } from '@nestjs/config'; @@ -166,12 +167,17 @@ export class ErrorHttpFilter implements ExceptionFilter { } sendToSentry(exception: unknown): void { - if (exception! instanceof HttpException) { - try { - this.sentryService.instance().captureException(exception); - } catch (err: unknown) {} + if ( + exception instanceof HttpException && + !(exception instanceof InternalServerErrorException) + ) { + return; } + try { + this.sentryService.instance().captureException(exception); + } catch (err: unknown) {} + return; } } diff --git a/src/common/request/request.module.ts b/src/common/request/request.module.ts index 7889a560b..8cd974cf7 100644 --- a/src/common/request/request.module.ts +++ b/src/common/request/request.module.ts @@ -42,9 +42,9 @@ import { LessThanConstraint } from 'src/common/request/validations/request.less- useFactory: () => new ValidationPipe({ transform: true, - skipNullProperties: true, + skipNullProperties: false, skipUndefinedProperties: false, - skipMissingProperties: true, + skipMissingProperties: false, forbidUnknownValues: false, errorHttpStatusCode: HttpStatus.UNPROCESSABLE_ENTITY, exceptionFactory: async (errors: ValidationError[]) =>