Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 17 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ on:
jobs:
eslint-check:
runs-on: self-hosted
timeout-minutes: 10
timeout-minutes: 2

steps:
# 코드 가져오기
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

# Node.js 환경 설정
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Lightning fast lint check
run: |
echo "⚡ Quick lint check..."

# 의존성 설치
- name: Install dependencies
run: npm ci
# 변경된 파일만 검사(전체가 아닌 2~3개 파일만)
CHANGED_FILES=$(git diff --name-only HEAD~1 -- '*.ts' '*.tsx' '*.js' '*.jsx')

# ESLint 실행
- name: Run ESLint
run: npm run lint
# 변경사항 없으면 즉시 종료
if [ -z "$CHANGED_FILES" ]; then
echo "✅ No JS/TS files changed"
exit 0
fi

# 글로벌 ESLint 사용
echo "📝 Checking: $CHANGED_FILES"
npx eslint $CHANGED_FILES
echo "✅ Lint check passed!"
58 changes: 29 additions & 29 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,51 @@ on:
branches: [main, develop]

jobs:
deploy:
if: github.event.pull_request.merged == true
# 환경 체크 단계 분리
warmup:
runs-on: self-hosted
timeout-minutes: 15
timeout-minutes: 3
steps:
- name: Environment check
run: |
echo "=== System Check ==="
whoami
docker --version
free -h # 메모리 상태 사전 체크
docker ps # 현재 컨테이너 상태

deploy:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

배포 조건에 머지 여부 확인 로직 추가 필요
현재 PR Close 시점에 무조건 배포됩니다. 머지된 경우에만 실행되도록 if: github.event.pull_request.merged == true를 추가하세요.

  deploy:
-   needs: warmup # ✅ warmup 완료 후 실행
+   needs: warmup # ✅ warmup 완료 후 실행
+   if: github.event.pull_request.merged == true
📝 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
deploy:
deploy:
needs: warmup # ✅ warmup 완료 후 실행
if: github.event.pull_request.merged == true
🤖 Prompt for AI Agents
In .github/workflows/deploy.yml at line 22, the deploy job currently runs
unconditionally when a PR is closed. To ensure deployment only occurs if the PR
was merged, add the condition `if: github.event.pull_request.merged == true` to
the deploy job definition. This will restrict the deployment step to run only
when the PR merge event is confirmed.

needs: warmup # ✅ warmup 완료 후 실행
runs-on: self-hosted
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Deploy to EC2
# 스크립트 분리
- name: Execute deployment script
run: |
echo "🚀 Starting deployment..."
echo "🔄 Branch: ${{ github.ref_name }}"
echo "🔄 Commit: ${{ github.sha }}"

# 메모리 정리
echo "🧹 Cleaning up memory..."
docker system prune -f

# 앱 디렉토리로 코드 복사
echo "📂 Copying files..."
rsync -av --delete \
--exclude='.git' \
--exclude='node_modules' \
--exclude='.next' \
./ /home/ubuntu/coplan/app/

# 배포 디렉토리로 이동
# 단순히 스크립트만 실행
cd /home/ubuntu/coplan
chmod +x ./deploy.sh
./deploy.sh

# Docker 컨테이너 재시작
echo "🔄 Restarting containers..."
docker compose down
docker compose up -d --build

# 헬스체크
# 헬스체크
- name: Health check
run: |
echo "🏥 Health checking..."
sleep 15

if docker ps | grep -q coplan-app; then
echo "✅ Deployment completed successfully!"
docker logs --tail 10 coplan-app
echo "🌐 Service available at: http://15.164.127.149"
if docker ps | grep -q $DOCKER_CONTAINER_NAME; then
echo "✅ Deployment completed!"
docker logs --tail 5 $DOCKER_CONTAINER_NAME
echo "🌐 https://coplan.work" # ✅ HTTPS
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

환경 변수 인용 및 기본값 검증
$DOCKER_CONTAINER_NAME이 설정되지 않으면 오류가 발생할 수 있습니다. 변수 인용 및 미설정 시 실패 로직을 추가하세요.

-          if docker ps | grep -q $DOCKER_CONTAINER_NAME; then
+          if [ -z "${DOCKER_CONTAINER_NAME:-}" ]; then
+            echo "❌ DOCKER_CONTAINER_NAME이 설정되지 않았습니다."
+            exit 1
+          fi
+          if docker ps | grep -q "$DOCKER_CONTAINER_NAME"; then
📝 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
if docker ps | grep -q $DOCKER_CONTAINER_NAME; then
echo "✅ Deployment completed!"
docker logs --tail 5 $DOCKER_CONTAINER_NAME
echo "🌐 https://coplan.work" # ✅ HTTPS
if [ -z "${DOCKER_CONTAINER_NAME:-}" ]; then
echo "❌ DOCKER_CONTAINER_NAME이 설정되지 않았습니다."
exit 1
fi
if docker ps | grep -q "$DOCKER_CONTAINER_NAME"; then
echo "✅ Deployment completed!"
docker logs --tail 5 $DOCKER_CONTAINER_NAME
echo "🌐 https://coplan.work" # ✅ HTTPS
🤖 Prompt for AI Agents
In .github/workflows/deploy.yml around lines 48 to 51, the script uses the
environment variable $DOCKER_CONTAINER_NAME without quotes or validation, which
can cause errors if the variable is unset or contains spaces. Fix this by
quoting the variable references like "$DOCKER_CONTAINER_NAME" and add a check
before this block to verify that $DOCKER_CONTAINER_NAME is set and non-empty,
exiting with an error message if it is not.

else
echo "❌ Deployment failed!"
docker logs coplan-app
docker logs $DOCKER_CONTAINER_NAME 2>/dev/null || echo "No logs"
exit 1
fi
Loading