Skip to content

Commit

Permalink
Merge pull request #499 from andrechristikan/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
andrechristikan committed Dec 7, 2023
2 parents befc2ca + 12dfaa1 commit d8e7c17
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 36 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,15 +32,14 @@ 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
uses: martinbeentjes/npm-get-version-action@main

- 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 }}
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -73,7 +73,7 @@ jobs:
with:
builder: ${{ steps.main.outputs.name }}
file: ${{ env.DOCKERFILE }}
args: |
build-args: |
NODE_ENV=production
target: main
tags: |
Expand All @@ -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



6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ permissions:

on:

# push:
# branches:
# - main
push:
branches:
- main
workflow_dispatch:

jobs:
Expand Down
14 changes: 10 additions & 4 deletions src/common/error/filters/error.http.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
HttpException,
HttpStatus,
Optional,
InternalServerErrorException,
} from '@nestjs/common';
import { HttpArgumentsHost } from '@nestjs/common/interfaces';
import { ConfigService } from '@nestjs/config';
Expand Down Expand Up @@ -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;
}
}
4 changes: 2 additions & 2 deletions src/common/request/request.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) =>
Expand Down

0 comments on commit d8e7c17

Please sign in to comment.