From 1479622f66a5461b4fc88b4555880461822bdc8f Mon Sep 17 00:00:00 2001 From: Maybeiley <2784519@gmail.com> Date: Sun, 23 Feb 2025 23:25:58 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Feat:=20#269=20=EC=9E=90=EB=8F=99=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20GitHub=20Actions=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..fa9c3d6 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,32 @@ +name: Deploy to EC2 + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + role-to-assume: arn:aws:iam::${{ AWS_USER_ID }}:role/${{ AWS_IAM_ROLE }} + aws-region: ap-northeast-2 + + - name: Set up SSH + uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Deploy to EC2 via SSH + run: | + ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.EC2_PUBLIC_IP }} "cd /var/www/app && git pull origin main && npm install && npm run build && pm2 start ecosystem.json" From ec00d9ebc8a09752e7ac9d823a6d608b98596864 Mon Sep 17 00:00:00 2001 From: Maybeiley <2784519@gmail.com> Date: Sun, 23 Feb 2025 23:26:43 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Feat:=20#269=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/notification.controller.ts | 23 ++----------------- test.json | 13 ----------- 2 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 test.json diff --git a/src/modules/notification/notification.controller.ts b/src/modules/notification/notification.controller.ts index fe1d378..111dd72 100644 --- a/src/modules/notification/notification.controller.ts +++ b/src/modules/notification/notification.controller.ts @@ -1,32 +1,13 @@ -import { Controller, Get, Param, Patch, Post, Sse } from '@nestjs/common'; +import { Controller, Get, Param, Patch, Sse } from '@nestjs/common'; import NotificationService from './notification.service'; import { UserId } from 'src/common/decorators/user.decorator'; import { interval, merge, Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { NotificationEventName, NotificationProperties } from './types/notification.types'; +import { NotificationProperties } from './types/notification.types'; @Controller('notifications') export default class NotificationController { constructor(private readonly service: NotificationService) {} - - @Post() - async createNotification(@UserId() userId: string) { - return await this.service.create({ - userId, - event: NotificationEventName.CONFIRM_QUOTE, - payload: { nickName: '테스트' } - }); - } - - @Post('2') - async createNotification2(@UserId() userId: string) { - return await this.service.create({ - userId, - event: NotificationEventName.SCHEDULE, - payload: { planTitle: '가현님이 좋아하는 플랜' } - }); - } - @Get() async getNotifications(@UserId() userId: string): Promise { return await this.service.get(userId); diff --git a/test.json b/test.json deleted file mode 100644 index 3be50e6..0000000 --- a/test.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Principal": { - "AWS": "arn:aws:iam::YOUR_EC2_ACCOUNT_ID:role/YOUR_IAM_ROLE_NAME" - }, - "Action": ["s3:GetObject", "s3:PutObject"], - "Resource": "arn:aws:s3:::TARGET_BUCKET_NAME/*" - } - ] -} From 2c70bf45149901609433489764e53bfb0d4f0035 Mon Sep 17 00:00:00 2001 From: Maybeiley <2784519@gmail.com> Date: Mon, 24 Feb 2025 01:10:07 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Feat:=20#269=20=EB=B0=B0=ED=8F=AC=20?= =?UTF-8?q?=EC=A0=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 65 ++++++++++++++++++- package.json | 2 +- .../notification/notification.e2e.spec.ts | 4 +- src/modules/payment/payment.e2e.spec.ts | 2 +- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fa9c3d6..10e188f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,13 +16,74 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 - - name: Configure AWS credentials + - name: Set Up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.18.0' + + - name: Install Dependencies + run: npm install + + - name: Run E2E Tests + env: + ENV: ${{ secrets.ENV }} + ACCESS_TOKEN_EXPIRY: ${{ secrets.ACCESS_TOKEN_EXPIRY }} + BUCKET_NAME: ${{ secrets.BUCKET_NAME }} + CHAT_ID: ${{ secrets.CHAT_ID }} + CHAT_ROOM_ID: ${{ secrets.CHAT_ROOM_ID }} + CLIENT_REDIRECT: ${{ secrets.CLIENT_REDIRECT }} + COMPLETED_PLAN_ID: ${{ secrets.COMPLETED_PLAN_ID }} + CONFIRMED_PLAN_ID: ${{ secrets.CONFIRMED_PLAN_ID }} + DATABASE_URL: ${{ secrets.DATABASE_URL }} + DE_ACTIVE_CHAT_ROOM_ID: ${{ secrets.DE_ACTIVE_CHAT_ROOM_ID }} + DREAMER1_EMAIL: ${{ secrets.DREAMER1_EMAIL }} + DREAMER1_ID: ${{ secrets.DREAMER1_ID }} + DREAMER1_NICKNAME: ${{ secrets.DREAMER1_NICKNAME }} + DREAMER1_PASSWORD: ${{ secrets.DREAMER1_PASSWORD }} + DREAMER2_ID: ${{ secrets.DREAMER2_ID }} + GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} + GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} + GOOGLE_REDIRECT: ${{ secrets.GOOGLE_REDIRECT }} + JWT_SECRET: ${{ secrets.JWT_SECRET }} + KAKAO_CLIENT_ID: ${{ secrets.KAKAO_CLIENT_ID }} + KAKAO_CLIENT_SECRET: ${{ secrets.KAKAO_CLIENT_SECRET }} + KAKAO_REDIRECT: ${{ secrets.KAKAO_REDIRECT }} + MAKER1_ID: ${{ secrets.MAKER1_ID }} + MONGO_AUTH_SOURCE: ${{ secrets.MONGO_AUTH_SOURCE }} + MONGO_DB_NAME: ${{ secrets.MONGO_DB_NAME }} + MONGO_PASS: ${{ secrets.MONGO_PASS }} + MONGO_URI: ${{ secrets.MONGO_URI }} + MONGO_USER: ${{ secrets.MONGO_USER }} + NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }} + NAVER_CLIENT_SECRET: ${{ secrets.NAVER_CLIENT_SECRET }} + NAVER_REDIRECT: ${{ secrets.NAVER_REDIRECT }} + NOTIFICATION_ID: ${{ secrets.NOTIFICATION_ID }} + OAUTH_GOOGLE_PROVIDER_ID: ${{ secrets.OAUTH_GOOGLE_PROVIDER_ID }} + OVERDUE_PLAN_ID: ${{ secrets.OVERDUE_PLAN_ID }} + PAYMENT_ID: ${{ secrets.PAYMENT_ID }} + PENDING_PLAN_ID: ${{ secrets.PENDING_PLAN_ID }} + PORT: ${{ secrets.PORT }} + QUOTE1_ID: ${{ secrets.QUOTE1_ID }} + QUOTE2_ID: ${{ secrets.QUOTE2_ID }} + REDIS_HOST: ${{ secrets.REDIS_HOST }} + REDIS_PORT: ${{ secrets.REDIS_PORT }} + REFRESH_TOKEN_EXPIRY: ${{ secrets.REFRESH_TOKEN_EXPIRY }} + S3_ACCESSKEY: ${{ secrets.S3_ACCESSKEY }} + S3_REGION: ${{ secrets.S3_REGION }} + S3_SECRET_ACCESSKEY: ${{ secrets.S3_SECRET_ACCESSKEY }} + TOKEN_NAME: ${{ secrets.TOKEN_NAME }} + TO_BE_COMPLETED_PLAN_ID: ${{ secrets.TO_BE_COMPLETED_PLAN_ID }} + TO_BE_DELETE_QUOTE_ID: ${{ secrets.TO_BE_DELETE_QUOTE_ID }} + V2_API_SECRET: ${{ secrets.V2_API_SECRET }} + run: npm run test:e2e + + - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v3 with: role-to-assume: arn:aws:iam::${{ AWS_USER_ID }}:role/${{ AWS_IAM_ROLE }} aws-region: ap-northeast-2 - - name: Set up SSH + - name: Set Up SSH uses: webfactory/ssh-agent@v0.7.0 with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} diff --git a/package.json b/package.json index 62455a9..f0b9131 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./jest-e2e.json", + "test:e2e": "jest src/modules/plan/plan.e2e.spec.ts src/modules/quote/quote.e2e.spec.ts src/modules/auth/auth.e2e.spec.ts src/modules/user/user.e2e.spec.ts src/modules/follow/follow.e2e.spec.ts src/modules/notification/notification.e2e.spec.ts src/modules/payment/payment.e2e.spec.ts src/modules/chatRoom/chatRoom.e2e.spec.ts src/modules/chat/chat.e2e.spec.ts src/modules/review/review.e2e.spec.ts --detectOpenHandles --coverage", "test:e2e:plan": "jest src/modules/plan/plan.e2e.spec.ts --detectOpenHandles --coverage", "test:e2e:quote": "jest src/modules/quote/quote.e2e.spec.ts --detectOpenHandles --coverage", "test:e2e:auth": "jest src/modules/auth/auth.e2e.spec.ts --detectOpenHandles --coverage", diff --git a/src/modules/notification/notification.e2e.spec.ts b/src/modules/notification/notification.e2e.spec.ts index a0227ea..5ea3715 100644 --- a/src/modules/notification/notification.e2e.spec.ts +++ b/src/modules/notification/notification.e2e.spec.ts @@ -5,7 +5,7 @@ import AppModule from 'src/app.module'; import GlobalExceptionFilter from 'src/common/filters/globalExceptionFilter'; import { RoleValues } from 'src/common/constants/role.type'; import AuthService from '../auth/auth.service'; -import { seed } from 'src/providers/database/mongoose/mongoose.seed'; +import { mongooseSeed } from 'src/providers/database/mongoose/mongoose.seed'; describe('Notification Test (e2e)', () => { let app: INestApplication; @@ -27,7 +27,7 @@ describe('Notification Test (e2e)', () => { await app.init(); const authService = app.get(AuthService); - await seed(); + await mongooseSeed(); dreamerToken = authService.createTokens({ userId: dreamerId, role: RoleValues.DREAMER }).accessToken; }); diff --git a/src/modules/payment/payment.e2e.spec.ts b/src/modules/payment/payment.e2e.spec.ts index 41e606e..30e9af9 100644 --- a/src/modules/payment/payment.e2e.spec.ts +++ b/src/modules/payment/payment.e2e.spec.ts @@ -7,7 +7,7 @@ import { RoleValues } from 'src/common/constants/role.type'; import AuthService from '../auth/auth.service'; import { mongooseSeed } from 'src/providers/database/mongoose/mongoose.seed'; import PaymentService from './payment.service'; -import { PaymentStatusEnum } from 'src/common/types/payment/payment.type'; +import { PaymentStatusEnum } from './types/payment.type'; describe('Payment Test (e2e)', () => { let app: INestApplication;