Conversation
Walkthrough기존에 사용하던 Spring 프로젝트의 GitHub Actions 배포 워크플로우( Changes
Sequence Diagram(s)sequenceDiagram
participant GitHub
participant EC2
GitHub->>GitHub: PR closed (develop 브랜치 대상)
GitHub->>GitHub: build job 실행 (JDK, Gradle, properties 설정, 빌드, JAR 생성)
GitHub->>EC2: SCP로 JAR 파일 전송
GitHub->>EC2: deploy job 실행 (SSH 접속)
EC2->>EC2: 기존 8080 포트 프로세스 종료
EC2->>EC2: JAR 백그라운드 실행 및 로그 기록
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (5)
.github/workflows/spring-ci.yaml (2)
34-38: 코드 커버리지 업로드 단계가 제거되었습니다
codecov/codecov-action단계가 사라져 커버리지 변동을 추적할 수 없습니다. 의도적 삭제라면 무시해도 되지만, 커버리지를 계속 확인해야 한다면 재도입을 권장합니다. 필요하시면 설정 예시를 제공해 드리겠습니다.
38-38: 파일 끝에 개행(Newline)이 없습니다
일부 린터와 git diff 설정에서 경고가 발생할 수 있습니다. EOF 개행을 추가해 주세요..github/workflows/Spring-develop-CD.yml (3)
1-2: 워크플로 이름 오타 – ‘Deplot’ → ‘Deploy’-name: Spring Deplot to EC2 +name: Spring Deploy to EC2
37-38: JAR 파일 패턴이 모호해 실패할 수 있습니다
*SNAPSHOT.jar가 둘 이상이거나 스냅샷이 아닌 빌드라면mv가 실패합니다.- run: mv ./build/libs/*SNAPSHOT.jar ./cd.jar + run: | + JAR=$(ls build/libs/*SNAPSHOT.jar | head -n 1) + mv "$JAR" cd.jar
66-66: EOF 개행이 없습니다
YAMLLint 경고를 피하려면 파일 끝에 빈 줄을 추가하세요.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/workflows/Spring-develop-CD.yml(1 hunks).github/workflows/spring-cd.yml(0 hunks).github/workflows/spring-ci.yaml(1 hunks)
💤 Files with no reviewable changes (1)
- .github/workflows/spring-cd.yml
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/spring-ci.yaml
[error] 38-38: no new line character at the end of file
(new-line-at-end-of-file)
.github/workflows/Spring-develop-CD.yml
[error] 66-66: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (2)
.github/workflows/spring-ci.yaml (2)
5-6: 브랜치 필터가 모든 브랜치를 포함합니다 – 의도한 설정인지 확인해주세요
branches: ["*"]설정은 태그 푸시까지 포함해 모든 브랜치(와 참조)에 대해 워크플로가 실행됩니다. 필요 이상으로 CI 트래픽이 증가할 수 있습니다.["main", "develop"]처럼 구체적으로 지정하거나branches-ignore를 병행하는 방안을 검토해 주세요.
15-20:java-version은 문자열로 명시하는 것이 안전합니다
공식 문서 예시는java-version: '17'처럼 따옴표로 감싼 문자열을 사용합니다. 정수 리터럴로 둘 경우 내부 파싱이나 캐싱 키 계산 시 예기치 않은 문제가 생길 여지가 있습니다.
- java-version: 17 + java-version: '17'
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: ["develop"] | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
PR closed 이벤트만으로는 머지 여부를 보장하지 못합니다
닫힌(PR closed) 후에도 ‘머지되지 않은 닫힘’이 포함됩니다. 머지된 경우에만 배포하려면 각 job 또는 step에 조건을 추가하세요.
if: github.event.pull_request.merged == true🤖 Prompt for AI Agents
In .github/workflows/Spring-develop-CD.yml around lines 3 to 7, the workflow
triggers on pull_request closed events but does not ensure the PR was merged. To
fix this, add a condition to each job or step using 'if:
github.event.pull_request.merged == true' so that deployment only occurs when
the PR is merged, not just closed.
| - name: application.properties 파일 설정 | ||
| run: | | ||
| mkdir -p src/main/resources | ||
| mkdir -p src/test/resources | ||
| echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.properties | ||
| echo "${{ secrets.TEST_APPLICATION_PROPERTIES }}" > ./src/test/resources/application.properties | ||
|
|
There was a problem hiding this comment.
echo로 secrets를 쓰면 줄바꿈·특수문자가 손실됩니다
멀티라인 secret(예: \n 포함) 은 cat <<'EOF' 구문으로 안전하게 기록하세요.
- echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.properties
- echo "${{ secrets.TEST_APPLICATION_PROPERTIES }}" > ./src/test/resources/application.properties
+ cat <<'EOF' > ./src/main/resources/application.properties
+${{ secrets.APPLICATION_PROPERTIES }}
+EOF
+ cat <<'EOF' > ./src/test/resources/application.properties
+${{ secrets.TEST_APPLICATION_PROPERTIES }}
+EOF📝 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.
| - name: application.properties 파일 설정 | |
| run: | | |
| mkdir -p src/main/resources | |
| mkdir -p src/test/resources | |
| echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.properties | |
| echo "${{ secrets.TEST_APPLICATION_PROPERTIES }}" > ./src/test/resources/application.properties | |
| - name: application.properties 파일 설정 | |
| run: | | |
| mkdir -p src/main/resources | |
| mkdir -p src/test/resources | |
| cat <<'EOF' > ./src/main/resources/application.properties | |
| ${{ secrets.APPLICATION_PROPERTIES }} | |
| EOF | |
| cat <<'EOF' > ./src/test/resources/application.properties | |
| ${{ secrets.TEST_APPLICATION_PROPERTIES }} | |
| EOF |
🤖 Prompt for AI Agents
In .github/workflows/Spring-develop-CD.yml around lines 24 to 30, the use of
echo to write secrets to application.properties causes loss of newlines and
special characters. Replace the echo commands with a here-document syntax using
cat <<'EOF' to safely write the multiline secrets preserving formatting. This
ensures the secrets are correctly written with all special characters intact.
| - name: SSH로 EC2에 접속하기 | ||
| uses: appleboy/ssh-action@v0.1.7 | ||
| with: | ||
| host: ${{ secrets.EC2_HOST }} | ||
| username: ${{ secrets.EC2_USER }} | ||
| key: ${{ secrets.EC2_SSH_KEY }} | ||
| script_stop: true | ||
| script: | | ||
| cd clue | ||
| sudo fuser -k -n tcp 8080 || true | ||
| sudo nohup java -jar cd.jar > ./output.log 2>&1 & No newline at end of file |
There was a problem hiding this comment.
🛠️ Refactor suggestion
백그라운드 실행/포트 종료 로직이 취약합니다
sudo nohup는 working dir가/root로 바뀌어cd.jar를 찾지 못할 위험이 있습니다.- 프로세스 관리를
systemd혹은pm2등으로 이관하면 재부팅·재시작 시 안정적입니다.
최소한 다음과 같이 경로를 절대경로로 지정하세요.
- sudo nohup java -jar cd.jar > ./output.log 2>&1 &
+ sudo nohup java -jar /home/ubuntu/clue/cd.jar > /home/ubuntu/clue/output.log 2>&1 &🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 66-66: no new line character at the end of file
(new-line-at-end-of-file)
🤖 Prompt for AI Agents
In .github/workflows/Spring-develop-CD.yml around lines 56 to 66, the SSH action
runs the Java jar with sudo nohup which changes the working directory to /root,
causing potential failure to find cd.jar. To fix this, replace relative paths
with absolute paths for cd.jar and output.log in the script. Additionally,
consider migrating process management to systemd or pm2 for better stability on
reboot or restart.
Summary by CodeRabbit