-
Notifications
You must be signed in to change notification settings - Fork 2
GitHub Actions를 활용한 CD 파이프라인 작성 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 34 commits
9873017
2381b08
606365e
614e9b1
e25cc0f
b9c9507
5d4a482
a0031ee
8e0d176
da966ff
5765bba
779cf35
64f00f5
fc05bf8
b8ec979
b148bb2
82f12be
efebd5a
48a7c56
326c88a
ae23e73
7b3d526
6eac5c7
5d03cff
fc88f8f
6ac725f
4a02140
30dee76
9b5cb8b
31c51ed
fdd457c
290f9e0
d90b977
d9dd5d3
8b0a23f
e828bff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,6 @@ | ||
| # DB | ||
| DB_URL="postgresql://postgres:1q2w3e4r@localhost:5432/postgres?schema=public" | ||
| DB_HOST=localhost | ||
| DB_PORT=5432 | ||
| DB_USER=postgres | ||
| DB_PASSWORD=1q2w3e4r | ||
| DB_NAME=postgres | ||
| DB_SCHEMA=public | ||
|
|
||
| PORT=8000 | ||
|
|
||
| # JWT | ||
| ACCESS_TOKEN_SECRET= | ||
| REFRESH_TOKEN_SECRET= |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Deploy serverless application | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - feat/cd | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'yarn' | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Run Prisma migrations | ||
| run: npx prisma migrate deploy 2>&1 | grep -v 'Datasource "db":' | grep -v 'PostgreSQL database' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 덕분에 쉘 명령어 다시 공부했네요ㅋㅋㅋㅋ 불필요한 정보 마스킹하는 것 잘 배워갑니다!
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 고마워 지피티야! |
||
| env: | ||
| DB_URL: ${{ secrets.DB_URL }} | ||
|
|
||
| - name: Create .env file | ||
| run: | | ||
| echo "ACCESS_TOKEN_SECRET=${{ secrets.ACCESS_TOKEN_SECRET }}" >> .env | ||
| echo "REFRESH_TOKEN_SECRET=${{ secrets.REFRESH_TOKEN_SECRET }}" >> .env | ||
| echo "DB_URL=${{ secrets.DB_URL }}" >> .env | ||
|
|
||
| - name: Run build | ||
| run: yarn build | ||
|
|
||
| - name: Configure serverless credentials | ||
| run: npx serverless config credentials --provider aws --key ${{ secrets.AWS_ACCESS_KEY_ID }} --secret ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
|
|
||
| - name: Deploy serverless app | ||
| run: npx serverless deploy 2>&1 | grep -v 'endpoint:' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Run build & test | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - feat/cd | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'yarn' | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Lint code | ||
| run: yarn lint | ||
|
|
||
| - name: Build project | ||
| run: yarn build | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,5 +61,3 @@ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | |
| postgres-data/ | ||
|
|
||
| graphql-schema.gql | ||
|
|
||
| @generated | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| graphql-schema.gql | ||
| @generated | ||
| graphql-schema.gql |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| }, | ||
| "dependencies": { | ||
| "@fastify/aws-lambda": "5.1.4", | ||
| "@nestjs/cli": "^11.0.6", | ||
| "@nestjs/common": "^11.0.1", | ||
| "@nestjs/config": "^4.0.2", | ||
| "@nestjs/core": "^11.0.1", | ||
|
|
@@ -35,8 +36,7 @@ | |
| "@nestjs/platform-express": "^11.0.1", | ||
| "@nestjs/platform-fastify": "11.0.12", | ||
| "@prisma/client": "^6.5.0", | ||
| "aws-lambda": "^1.0.7", | ||
| "bcrypt": "^5.1.1", | ||
| "bcryptjs": "^3.0.2", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ref 확인했습니다 |
||
| "class-transformer": "^0.5.1", | ||
| "class-validator": "^0.14.1", | ||
| "fastify": "5.2.1", | ||
|
|
@@ -52,7 +52,6 @@ | |
| "devDependencies": { | ||
| "@eslint/eslintrc": "^3.2.0", | ||
| "@eslint/js": "^9.18.0", | ||
| "@nestjs/cli": "^11.0.0", | ||
| "@nestjs/schematics": "^11.0.0", | ||
| "@nestjs/testing": "^11.0.1", | ||
| "@swc/cli": "^0.6.0", | ||
|
|
@@ -71,6 +70,7 @@ | |
| "globals": "^16.0.0", | ||
| "jest": "^29.7.0", | ||
| "prettier": "^3.4.2", | ||
| "serverless": "3.38.0", | ||
| "serverless-dotenv-plugin": "^6.0.0", | ||
| "source-map-support": "^0.5.21", | ||
| "supertest": "^7.0.0", | ||
|
|
@@ -98,4 +98,4 @@ | |
| "coverageDirectory": "../coverage", | ||
| "testEnvironment": "node" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| org: hospace | ||
| app: mashup-node | ||
|
|
||
| service: nest-graphql-mercurius-fastify | ||
|
|
||
| plugins: | ||
|
|
@@ -30,3 +27,4 @@ package: | |
| - 'node_modules/.prisma/client/libquery_engine-rhel-*' | ||
| - '!node_modules/prisma/libquery_engine-*' | ||
| - '!node_modules/@prisma/engines/**' | ||
| - '!node_modules/aws-lambda' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ObjectType } from '@nestjs/graphql'; | ||
| import { PostCountAggregate } from './post-count-aggregate.output'; | ||
| import { PostMinAggregate } from './post-min-aggregate.output'; | ||
| import { PostMaxAggregate } from './post-max-aggregate.output'; | ||
|
|
||
| @ObjectType() | ||
| export class AggregatePost { | ||
|
|
||
| @Field(() => PostCountAggregate, {nullable:true}) | ||
| _count?: PostCountAggregate; | ||
|
|
||
| @Field(() => PostMinAggregate, {nullable:true}) | ||
| _min?: PostMinAggregate; | ||
|
|
||
| @Field(() => PostMaxAggregate, {nullable:true}) | ||
| _max?: PostMaxAggregate; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { PostCreateManyInput } from './post-create-many.input'; | ||
| import { Type } from 'class-transformer'; | ||
|
|
||
| @ArgsType() | ||
| export class CreateManyPostArgs { | ||
|
|
||
| @Field(() => [PostCreateManyInput], {nullable:false}) | ||
| @Type(() => PostCreateManyInput) | ||
| data!: Array<PostCreateManyInput>; | ||
|
|
||
| @Field(() => Boolean, {nullable:true}) | ||
| skipDuplicates?: boolean; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { PostCreateInput } from './post-create.input'; | ||
| import { Type } from 'class-transformer'; | ||
|
|
||
| @ArgsType() | ||
| export class CreateOnePostArgs { | ||
|
|
||
| @Field(() => PostCreateInput, {nullable:false}) | ||
| @Type(() => PostCreateInput) | ||
| data!: PostCreateInput; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { PostWhereInput } from './post-where.input'; | ||
| import { Type } from 'class-transformer'; | ||
| import { Int } from '@nestjs/graphql'; | ||
|
|
||
| @ArgsType() | ||
| export class DeleteManyPostArgs { | ||
|
|
||
| @Field(() => PostWhereInput, {nullable:true}) | ||
| @Type(() => PostWhereInput) | ||
| where?: PostWhereInput; | ||
|
|
||
| @Field(() => Int, {nullable:true}) | ||
| limit?: number; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { Prisma } from '@prisma/client'; | ||
| import { PostWhereUniqueInput } from './post-where-unique.input'; | ||
| import { Type } from 'class-transformer'; | ||
|
|
||
| @ArgsType() | ||
| export class DeleteOnePostArgs { | ||
|
|
||
| @Field(() => PostWhereUniqueInput, {nullable:false}) | ||
| @Type(() => PostWhereUniqueInput) | ||
| where!: Prisma.AtLeast<PostWhereUniqueInput, 'id'>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { PostWhereInput } from './post-where.input'; | ||
| import { Type } from 'class-transformer'; | ||
| import { PostOrderByWithRelationInput } from './post-order-by-with-relation.input'; | ||
| import { Prisma } from '@prisma/client'; | ||
| import { PostWhereUniqueInput } from './post-where-unique.input'; | ||
| import { Int } from '@nestjs/graphql'; | ||
| import { PostScalarFieldEnum } from './post-scalar-field.enum'; | ||
|
|
||
| @ArgsType() | ||
| export class FindFirstPostOrThrowArgs { | ||
|
|
||
| @Field(() => PostWhereInput, {nullable:true}) | ||
| @Type(() => PostWhereInput) | ||
| where?: PostWhereInput; | ||
|
|
||
| @Field(() => [PostOrderByWithRelationInput], {nullable:true}) | ||
| orderBy?: Array<PostOrderByWithRelationInput>; | ||
|
|
||
| @Field(() => PostWhereUniqueInput, {nullable:true}) | ||
| cursor?: Prisma.AtLeast<PostWhereUniqueInput, 'id'>; | ||
|
|
||
| @Field(() => Int, {nullable:true}) | ||
| take?: number; | ||
|
|
||
| @Field(() => Int, {nullable:true}) | ||
| skip?: number; | ||
|
|
||
| @Field(() => [PostScalarFieldEnum], {nullable:true}) | ||
| distinct?: Array<`${PostScalarFieldEnum}`>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { PostWhereInput } from './post-where.input'; | ||
| import { Type } from 'class-transformer'; | ||
| import { PostOrderByWithRelationInput } from './post-order-by-with-relation.input'; | ||
| import { Prisma } from '@prisma/client'; | ||
| import { PostWhereUniqueInput } from './post-where-unique.input'; | ||
| import { Int } from '@nestjs/graphql'; | ||
| import { PostScalarFieldEnum } from './post-scalar-field.enum'; | ||
|
|
||
| @ArgsType() | ||
| export class FindFirstPostArgs { | ||
|
|
||
| @Field(() => PostWhereInput, {nullable:true}) | ||
| @Type(() => PostWhereInput) | ||
| where?: PostWhereInput; | ||
|
|
||
| @Field(() => [PostOrderByWithRelationInput], {nullable:true}) | ||
| orderBy?: Array<PostOrderByWithRelationInput>; | ||
|
|
||
| @Field(() => PostWhereUniqueInput, {nullable:true}) | ||
| cursor?: Prisma.AtLeast<PostWhereUniqueInput, 'id'>; | ||
|
|
||
| @Field(() => Int, {nullable:true}) | ||
| take?: number; | ||
|
|
||
| @Field(() => Int, {nullable:true}) | ||
| skip?: number; | ||
|
|
||
| @Field(() => [PostScalarFieldEnum], {nullable:true}) | ||
| distinct?: Array<`${PostScalarFieldEnum}`>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { PostWhereInput } from './post-where.input'; | ||
| import { Type } from 'class-transformer'; | ||
| import { PostOrderByWithRelationInput } from './post-order-by-with-relation.input'; | ||
| import { Prisma } from '@prisma/client'; | ||
| import { PostWhereUniqueInput } from './post-where-unique.input'; | ||
| import { Int } from '@nestjs/graphql'; | ||
| import { PostScalarFieldEnum } from './post-scalar-field.enum'; | ||
|
|
||
| @ArgsType() | ||
| export class FindManyPostArgs { | ||
|
|
||
| @Field(() => PostWhereInput, {nullable:true}) | ||
| @Type(() => PostWhereInput) | ||
| where?: PostWhereInput; | ||
|
|
||
| @Field(() => [PostOrderByWithRelationInput], {nullable:true}) | ||
| orderBy?: Array<PostOrderByWithRelationInput>; | ||
|
|
||
| @Field(() => PostWhereUniqueInput, {nullable:true}) | ||
| cursor?: Prisma.AtLeast<PostWhereUniqueInput, 'id'>; | ||
|
|
||
| @Field(() => Int, {nullable:true}) | ||
| take?: number; | ||
|
|
||
| @Field(() => Int, {nullable:true}) | ||
| skip?: number; | ||
|
|
||
| @Field(() => [PostScalarFieldEnum], {nullable:true}) | ||
| distinct?: Array<`${PostScalarFieldEnum}`>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { Prisma } from '@prisma/client'; | ||
| import { PostWhereUniqueInput } from './post-where-unique.input'; | ||
| import { Type } from 'class-transformer'; | ||
|
|
||
| @ArgsType() | ||
| export class FindUniquePostOrThrowArgs { | ||
|
|
||
| @Field(() => PostWhereUniqueInput, {nullable:false}) | ||
| @Type(() => PostWhereUniqueInput) | ||
| where!: Prisma.AtLeast<PostWhereUniqueInput, 'id'>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { Field } from '@nestjs/graphql'; | ||
| import { ArgsType } from '@nestjs/graphql'; | ||
| import { Prisma } from '@prisma/client'; | ||
| import { PostWhereUniqueInput } from './post-where-unique.input'; | ||
| import { Type } from 'class-transformer'; | ||
|
|
||
| @ArgsType() | ||
| export class FindUniquePostArgs { | ||
|
|
||
| @Field(() => PostWhereUniqueInput, {nullable:false}) | ||
| @Type(() => PostWhereUniqueInput) | ||
| where!: Prisma.AtLeast<PostWhereUniqueInput, 'id'>; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd 과정을 여러 개로 나누는 걸 처음 봤는데, 유연하게 사용할 수 있는 게 큰 장점인 것 같아요 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
장단이 있는 것 같습니다.
책임 분리 측면에서는 장점을 가집니다.
기존에 @hye-on 님이 해주신 방식의 경우에는 중복 로직을 제거할 수 있다는 장점을 가졌었죠!
상황에 따라 선택하면 좋아보입니다!