Skip to content

GitHub Actions를 활용한 CD 파이프라인 작성#10

Merged
hye-on merged 36 commits intomainfrom
feat/cd
May 16, 2025
Merged

GitHub Actions를 활용한 CD 파이프라인 작성#10
hye-on merged 36 commits intomainfrom
feat/cd

Conversation

@hye-on
Copy link
Collaborator

@hye-on hye-on commented Apr 22, 2025

📝 작업 내용

cd 작업했습니다.

💬 리뷰 요구사항(선택)

전체적인 플로우 봐주세요!
더 좋은 문제 해결법이 있을 것 같은데,, 혹시 아는 거 있으면 알려주세요! :)

⛔ serverless 버전4에서는 로그인 필수

Error: You must sign in or use a license key with Serverless Framework V.4 and later versions. Please use "serverless login".
=>Serverless Framework v4부터 로그인이나 라이선스 키가 필요

실패한 github action

=> 🔑 3.38.0로 버전 낮춰서 해결
-> 나중에 라이선스 키 받으면 4로 올려도 좋을 것 같아요

⛔ 플러그인 충돌

TypeError: Cannot redefine property: _serverlessExternalPluginName
실패한 github action

시도한 방법
https://forum.serverless.com/t/cannot-redefine-property-serverlessexternalpluginname/20666
serverless/serverless#12936
-> 이거 보고 노드 버전 수정해봤는데 해결안되었습니다.

=> 🔑
serverless.yml에서 플러그인 주석 처리해서 해결
CI/CD 배포 단계에서 필요없는 플러그인 인것같아서 주석처리 했는데 문제 없으면 주석 삭제해서 커밋하겠습니다.

plugins:
#  - serverless-offline
#  - serverless-dotenv-plugin

⛔ 패키지 사이즈 너무 커서 람다 배포안되는 문제

실패한 github action

=> 🔑 serverless.yml에 - '!node_modules/.pnpm/**' 추가
임시방편 인 것 같아서 조금 더 이유를 찾아볼께요.

⛔ 서울 리전 지원안되는 문제

https://www.serverless.com/framework/docs/guides/dashboard/cicd/running-in-your-own-cicd#configure-environment-variables

image

SERVERLESS_ACCESS_KEY로 하면 대시보드에 엑세스하는데 대시보드 모드가 서울리전이 지원안되는 것 같아요.

실패한 github action

=> 🔑 SERVERLESS_ACCESS_KEY 사용안하고 AWS 자격 증명(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)만 사용

아래 코드 주석처리 해서 대시보드 기능 비활성화
(혹시 아니면 말해주세욤)

serverless.yml

#org: hospace
#app: mashup-node

📚 참고할만한 자료(선택)

@hye-on hye-on self-assigned this Apr 22, 2025
@hye-on hye-on requested review from Ho-s, Copilot and labyrinth30 April 22, 2025 13:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a CD pipeline using GitHub Actions to deploy a Serverless application to AWS Lambda while addressing issues related to Serverless framework version compatibility, plugin conflicts, and package size constraints.

  • Commented out Serverless dashboard configuration settings (org and app) to avoid login/license issues.
  • Added an exclusion rule for pnpm-managed modules in the packaging configuration.
  • Introduced a new GitHub Actions workflow for validation, building, and deployment of the application.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
serverless.yml Disabled dashboard configuration and updated packaging exclusions.
.github/workflows/deploy.yml Added a new workflow to validate, build, and deploy the app to AWS Lambda.
Files not reviewed (1)
  • package.json: Language not supported
Comments suppressed due to low confidence (1)

serverless.yml:7

  • Commenting out these serverless plugins prevents local development scenarios from running as expected. Please confirm that these plugins are not required in non-CI environments or consider using conditional inclusion.
# - serverless-offline

name: build-artifact
path: |
dist/
node_modules/
Copy link

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including the entire node_modules directory in the build artifact may lead to an excessively large deployment package. Consider excluding it if not required for deployment to mitigate potential packaging issues.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@Ho-s Ho-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빠르고 정확한 작업... 고군 분투의 흔적이 보입니다! 너무 고생하셨어요! 🔥🔥🔥🔥🔥

run: yarn build

- name: Upload build artifact
uses: actions/upload-artifact@v3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 친구는 뭐 할 때 사용하는 액션인가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빌드 결과물을 저장하고 공유하는 사용합니다!
다른 워크플로우 작업이나 단계에서 빌드 결과물을 공유하기 위해 사용했습니다!

현재 2개 두 개의 별도 작업으로 구성되어 있습니다.

  • validate 작업: 코드를 체크아웃하고, 의존성을 설치하고, 빌드하는 작업
  • deploy 작업: 빌드된 결과물을 AWS Lambda에 배포하는 작업

AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DB_URL: ${{ secrets.DB_URL }}
DB_HOST: ${{ secrets.DB_HOST }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존에는 PORTDB_URL 만 쓰고 있습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d90b977 제거했습니다!

Copy link
Member

@labyrinth30 labyrinth30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서버리스로 CD하는 건 저도 익숙치 않네요. 진행하시면서 엄청 고생하신 것 같습니다!
토요일에 같이 이야기하면 좋을 것 같습니다!

"@prisma/client": "^6.5.0",
"aws-lambda": "^1.0.7",
"bcrypt": "^5.1.1",
"bcryptjs": "^3.0.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref 확인했습니다

return ctx.getContext().req.user;
(_: unknown, context: ExecutionContext) => {
const gqlContext = GqlExecutionContext.create(context);
const { user } = gqlContext.getContext<GraphQLContext>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제네릭으로 타입 명시하니까 타입 안정성도 높이고, 명확성과 유지보수성도 높아지는 것 같습니다👍

- npx prisma generate 는 삭제 -> yarn install 시 prisma 내부 postinstall 로 shcema에 따라 자동 생성
@hye-on
Copy link
Collaborator Author

hye-on commented May 9, 2025

@Ho-s 수정 감사합니다 ! 👍

@hye-on hye-on requested review from Ho-s and labyrinth30 May 9, 2025 08:30
Copy link
Member

@labyrinth30 labyrinth30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

병호형이 말한 것처럼 @generated만 없어지면 좋을 것 같습니다!

run: yarn install --frozen-lockfile

- name: Run Prisma migrations
run: npx prisma migrate deploy 2>&1 | grep -v 'Datasource "db":' | grep -v 'PostgreSQL database'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

덕분에 쉘 명령어 다시 공부했네요ㅋㅋㅋㅋ 불필요한 정보 마스킹하는 것 잘 배워갑니다!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고마워 지피티야!

- 'node_modules/.prisma/client/libquery_engine-rhel-*'
- '!node_modules/prisma/libquery_engine-*'
- '!node_modules/@prisma/engines/**'
- '!node_modules/aws-lambda'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,29 @@
name: Run build & test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,43 @@
name: Deploy serverless application
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cd 과정을 여러 개로 나누는 걸 처음 봤는데, 유연하게 사용할 수 있는 게 큰 장점인 것 같아요 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

장단이 있는 것 같습니다.

책임 분리 측면에서는 장점을 가집니다.
기존에 @hye-on 님이 해주신 방식의 경우에는 중복 로직을 제거할 수 있다는 장점을 가졌었죠!

상황에 따라 선택하면 좋아보입니다!

@labyrinth30 labyrinth30 self-requested a review May 15, 2025 13:14
Copy link
Collaborator

@Ho-s Ho-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥🔥🔥🔥🔥

@hye-on hye-on merged commit 8b217cd into main May 16, 2025
1 check passed
@hye-on hye-on deleted the feat/cd branch May 16, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants