Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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: 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
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"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 2 additions & 21 deletions src/modules/notification/notification.controller.ts
Original file line number Diff line number Diff line change
@@ -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<NotificationProperties[]> {
return await this.service.get(userId);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/notification/notification.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +27,7 @@ describe('Notification Test (e2e)', () => {
await app.init();

const authService = app.get<AuthService>(AuthService);
await seed();
await mongooseSeed();

dreamerToken = authService.createTokens({ userId: dreamerId, role: RoleValues.DREAMER }).accessToken;
});
Expand Down
2 changes: 1 addition & 1 deletion src/modules/payment/payment.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 0 additions & 13 deletions test.json

This file was deleted.