Skip to content

Conversation

@Daae-Kim
Copy link
Member

@Daae-Kim Daae-Kim commented May 20, 2025

📌 관련 이슈

#249

✒️ 작업 내용

  1. 운영용 cd 파일 추가했습니다.
  2. 운영용 배포 스크립트를 작성했습니다.

스크린샷 🏞️ (선택)

💬 REVIEWER에게 요구사항 💬

Summary by CodeRabbit

  • Chores
    • 병합된 PR이 release 브랜치에 닫힐 때 자동으로 프로덕션 서버에 배포하는 GitHub Actions 워크플로우가 추가되었습니다.
    • 배포 후 API 상태를 확인하고, 결과를 슬랙으로 알림을 발송하는 기능이 포함되었습니다.
    • 배포 자동화를 위한 신규 셸 스크립트가 도입되었습니다.

@Daae-Kim Daae-Kim requested review from kssumin and rlajm1203 May 20, 2025 07:12
@Daae-Kim Daae-Kim self-assigned this May 20, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 20, 2025

Walkthrough

프로덕션 환경 배포를 위한 새로운 GitHub Actions 워크플로우와 자동화 배포 스크립트가 추가되었습니다. 워크플로우는 release 브랜치로 병합된 PR이 닫힐 때 트리거되며, 배포, 헬스 체크, Slack 알림 순으로 세 가지 작업을 순차적으로 실행합니다.

Changes

파일/경로 변경 요약
.github/workflows/backend-cd-prod.yml release 브랜치로 병합된 PR에 대해 배포, 헬스 체크, Slack 알림을 수행하는 새로운 워크플로우 추가
eeos/scripts/deploy-product.sh release 브랜치 최신 코드로 리셋, Gradle 빌드, 프로덕션 Docker Compose 컨테이너 재시작 자동화 스크립트 추가

Sequence Diagram(s)

sequenceDiagram
    participant GitHub
    participant Workflow
    participant ProdServer
    participant HealthCheck
    participant Slack

    GitHub->>Workflow: PR merge to release & close
    Workflow->>ProdServer: SSH 접속 후 deploy-product.sh 실행
    ProdServer-->>Workflow: 배포 완료
    Workflow->>HealthCheck: 20초 대기 후 API 헬스 체크
    HealthCheck-->>Workflow: 상태 코드 반환 (200/실패/타임아웃)
    Workflow->>Slack: 배포 및 헬스 체크 결과 Slack 알림 전송
Loading

Possibly related PRs

  • JNU-econovation/EEOS-BE#248: 개발 배포 워크플로우를 분할하여 배포, 헬스 체크, Slack 알림을 별도 작업으로 구현한 PR로, 이번 프로덕션 배포 워크플로우와 구조적으로 유사합니다.
  • JNU-econovation/EEOS-BE#228: 개발 환경용 CD 워크플로우 및 스크립트를 추가한 PR로, 이번 PR과 목적은 다르나 배포 자동화 방식이 유사합니다.
  • JNU-econovation/EEOS-BE#230: 개발 배포 워크플로우에 헬스 체크 및 Slack 알림을 통합한 PR로, 프로덕션 워크플로우 확장에 기반이 되는 변경입니다.

Suggested reviewers

  • rlajm1203
  • kssumin

Poem

배포 토끼가 깡총깡총,
릴리즈 브랜치 따라 점프!
스크립트 돌고, 서버는 춤추고,
헬스 체크 OK, 슬랙에 소식 뿅!
오늘도 평화로운 EEOS의 밤,
자동화 덕분에 토끼는 꿀잠~ 🐰✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

Test Results

89 tests  ±0   86 ✅ ±0   4s ⏱️ -1s
35 suites ±0    3 💤 ±0 
35 files   ±0    0 ❌ ±0 

Results for commit b22c489. ± Comparison against base commit cb976c2.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (10)
eeos/scripts/deploy-product.sh (3)

5-7: Git 명령 실행 위치 보장
스크립트가 eeos 하위 디렉터리에서 호출될 때 .git 루트를 찾지 못할 수 있습니다.
명령 실행 전 항상 레포지토리 루트로 이동하도록 다음을 추가하세요:

cd "$(git rev-parse --show-toplevel)"

8-8: Gradle 빌드 캐시·데몬 옵션 강화
./gradlew build -x test 대신 깨끗한 빌드를 위해

./gradlew clean build -x test --no-daemon

옵션 사용을 고려하세요.


10-12: Docker Compose 배포 옵션 강화
컨테이너 잔여물 및 오프라인 이미지를 방지하려면 다음과 같은 플래그 추가를 권장합니다:

-sudo docker-compose -f docker-compose-prod.yml down
-sudo docker-compose -f docker-compose-prod.yml up --build -d
+sudo docker-compose -f docker-compose-prod.yml down --remove-orphans
+sudo docker-compose -f docker-compose-prod.yml up --build --force-recreate -d

필요 시 docker-compose pull 로 이미지 업데이트도 고려하세요.

.github/workflows/backend-cd-prod.yml (7)

1-7: 동시 배포 충돌 방지: concurrency 도입 제안
여러 PR 병합 시 중복 배포를 막고자 workflow 최상단에 아래 설정을 추가하면 좋습니다.

concurrency:
  group: 'deploy-${{ github.event.pull_request.base.ref }}'
  cancel-in-progress: false

15-20: SSH 액션 버전 및 인증 방식 검토
appleboy/[email protected] 대신 커밋 SHA 고정 또는 최신 릴리즈 버전 사용을 고려하고, 가능하다면 password 대신 SSH 키 기반 인증(privateKey)으로 전환하여 보안 수준을 높이세요.


44-45: 하드코딩된 대기 시간 개선
20초 고정 대기(sleep 20) 대신 재시도 루프나 readiness probe를 활용하여 컨테이너 준비 여부를 동적으로 확인하는 로직으로 대체하면 안정성이 향상됩니다.


46-49: curl 실패 검증 및 변수 인용 강화

  • if [ $? -ne 0 ] 대신 if ! curl ...; then 으로 직접 실패를 체크
  • $GITHUB_OUTPUT"$GITHUB_OUTPUT" 로 이중 인용해 globbing/word splitting 방지
- if [ $? -ne 0 ]; then
+ if ! curl -s -o /dev/null -w "%{http_code}" --max-time 10 "$HEALTH_URL"; then
      echo "status=timeout" >> "$GITHUB_OUTPUT"

45-45: API 엔드포인트 하드코딩 제거
헬스체크 URL을 직접 지정하기보다 workflow env 또는 repository secret으로 추출하여 유지보수성을 높이세요.


138-138: trailing spaces 제거
138행 끝에 trailing space가 포함되어 있습니다. 편집기나 lint 설정으로 자동 제거해 주세요.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 138-138: trailing spaces

(trailing-spaces)


140-140: 파일 끝에 newline 추가
YAML 끝에 빈 줄을 한 줄 추가하여 POSIX 호환성과 린터 요구사항을 충족시키세요.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 140-140: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb976c2 and b22c489.

📒 Files selected for processing (2)
  • .github/workflows/backend-cd-prod.yml (1 hunks)
  • eeos/scripts/deploy-product.sh (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/backend-cd-prod.yml

42-42: shellcheck reported issue in this script: SC2181:style:4:6: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?

(shellcheck)


42-42: shellcheck reported issue in this script: SC2086:info:6:28: Double quote to prevent globbing and word splitting

(shellcheck)


42-42: shellcheck reported issue in this script: SC2086:info:8:28: Double quote to prevent globbing and word splitting

(shellcheck)


42-42: shellcheck reported issue in this script: SC2086:info:10:28: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 YAMLlint (1.37.1)
.github/workflows/backend-cd-prod.yml

[error] 138-138: trailing spaces

(trailing-spaces)


[error] 140-140: no new line character at the end of file

(new-line-at-end-of-file)

Comment on lines +1 to +4
#!/bin/sh

set -ex

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

set -ex 대신 stricter 옵션 적용 제안
현재 set -ex 만 사용 중인데, undefined 변수나 파이프 실패를 잡지 못합니다.

-#!/bin/sh
-set -ex
+#!/usr/bin/env bash
+set -euxo pipefail

를 적용하여 스크립트 안정성을 높이는 것을 권장합니다.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/sh
set -ex
#!/usr/bin/env bash
set -euxo pipefail
🤖 Prompt for AI Agents
In eeos/scripts/deploy-product.sh at lines 1 to 4, replace the current 'set -ex'
with stricter shell options by adding 'set -euo pipefail' to improve script
robustness. This change will make the script exit on errors, treat unset
variables as errors, and catch failures in pipelines, enhancing overall
stability.


jobs:
deploy:
if: github.event.pull_request.merged == true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

if 조건식 표현 오류
if: github.event.pull_request.merged == true${{ }} 없이는 항상 truthy 문자열로 평가됩니다.

if: ${{ github.event.pull_request.merged == true }}

또는

if: ${{ github.event.pull_request.merged }}

로 수정해야 의도대로 동작합니다.

🤖 Prompt for AI Agents
In .github/workflows/backend-cd-prod.yml at line 10, the if condition is missing
the required expression syntax and is treated as a string. Fix this by wrapping
the condition in ${{ }} like if: ${{ github.event.pull_request.merged == true }}
or simplify to if: ${{ github.event.pull_request.merged }} to ensure it
evaluates correctly.

@Daae-Kim Daae-Kim merged commit 7c6de32 into develop Sep 24, 2025
6 checks passed
@Daae-Kim Daae-Kim deleted the DD/chore/#249/cd-prod branch September 24, 2025 14:43
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.

3 participants