Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
82 changes: 82 additions & 0 deletions .github/workflows/deploy-admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Dev Admin CI/CD

on:
push:
branches:
- develop
paths:
- 'application-admin/**'
- 'common/**'
- 'domain-*/**'
- 'application-config/**'
- 'security-admin/**'
- 'build.gradle'
- 'settings.gradle'
- 'gradle/**'

Comment on lines +7 to +16
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

잘못된 들여쓰기 및 공백으로 YAMLLint 오류 발생

paths: 이하의 들여쓰기가 4칸이 아니라 6칸으로 되어 있어 YAML 구문 오류(trailing-spaces / indentation)가 보고되었습니다. CI/CD 워크플로우가 아예 로드되지 않을 수 있으니 반드시 수정해 주세요.

-    paths:
-      - 'application-admin/**'
-      - 'common/**'
-      - 'domain-*/**'
-      - 'application-config/**'
-      - 'security-admin/**'
-      - 'build.gradle'
-      - 'settings.gradle'
-      - 'gradle/**'
+    paths:
+      - 'application-admin/**'
+      - 'common/**'
+      - 'domain-*/**'
+      - 'application-config/**'
+      - 'security-admin/**'
+      - 'build.gradle'
+      - 'settings.gradle'
+      - 'gradle/**'

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 8-8: wrong indentation: expected 4 but found 6

(indentation)

🤖 Prompt for AI Agents
In .github/workflows/deploy-admin.yml around lines 7 to 16, the indentation
under the 'paths:' key is incorrect with 6 spaces instead of the required 4
spaces, causing YAML syntax errors. Fix this by adjusting the indentation of all
lines under 'paths:' to use exactly 4 spaces, and remove any trailing spaces to
comply with YAML linting rules and ensure the workflow loads correctly.

env:
PROJECT_NAME: NoWait
DIVISION: admin
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: nowait-deploy-github-actions
AWS_CODE_DEPLOY_APPLICATION: nowaiting
AWS_CODE_DEPLOY_GROUP: nowaiting-deploy-dev-admin

jobs:
build-with-gradle:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'

- name: gradlew에 실행 권한 부여
run: chmod +x ./gradlew

- name: Set YML
run: |
mkdir -p application-admin/src/main/resources
echo "${{ secrets.APPLICATION_DEV_ADMIN_YML }}" | base64 --decode > application-admin/src/main/resources/application-admin.yml
find src
- name: 프로젝트 빌드
run: ./gradlew clean :application-admin:bootJar -x test

- name: Prepare deployment package
run: |
rm -rf deploy && mkdir deploy
cp application-admin/build/libs/application-admin-*.jar deploy/application-admin.jar
cp scripts/start-admin.sh scripts/stop-admin.sh appspec-admin.yml deploy/appspec.yml
cd deploy
zip -r ../${{ env.PROJECT_NAME }}-${{ env.DIVISION }}-${{ github.sha }}.zip .
cd ..
- name: AWS credential 설정
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.DEVSERVER_CICD_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.DEVSERVER_CICD_SECRET_KEY }}

- name: S3에 업로드
run: aws deploy push \
--application-name "${{ env.AWS_CODE_DEPLOY_APPLICATION }}" \
--ignore-hidden-files \
--s3-location "s3://${{ env.AWS_S3_BUCKET }}/${{ env.PROJECT_NAME }}/${{ env.DIVISION }}/${{ github.sha }}.zip" \
--source "${{ env.PROJECT_NAME }}-${{ env.DIVISION }}-${{ github.sha }}.zip"

Comment on lines +55 to +72
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

ZIP 생성 후 aws deploy push 이중 압축 문제

이미 zip 명령으로 파일을 만들었는데 aws deploy push --source <zip파일> 은 디렉터리를 재압축합니다.
가장 간단한 해결책은 aws s3 cp 로 ZIP 을 업로드하고 create-deployment 시 해당 S3 객체를 지정하는 것입니다.

-    - name: S3에 업로드
-      run: aws deploy push \
-        --application-name "${{ env.AWS_CODE_DEPLOY_APPLICATION }}" \
-        --ignore-hidden-files \
-        --s3-location "s3://${{ env.AWS_S3_BUCKET }}/${{ env.PROJECT_NAME }}/${{ env.DIVISION }}/${{ github.sha }}.zip" \
-        --source "${{ env.PROJECT_NAME }}-${{ env.DIVISION }}-${{ github.sha }}.zip"
+    - name: S3에 업로드
+      run: aws s3 cp \
+        "${{ env.PROJECT_NAME }}-${{ env.DIVISION }}-${{ github.sha }}.zip" \
+        "s3://${{ env.AWS_S3_BUCKET }}/${{ env.PROJECT_NAME }}/${{ env.DIVISION }}/${{ github.sha }}.zip"
📝 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
cd deploy
zip -r ../${{ env.PROJECT_NAME }}-${{ env.DIVISION }}-${{ github.sha }}.zip .
cd ..
- name: AWS credential 설정
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.DEVSERVER_CICD_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.DEVSERVER_CICD_SECRET_KEY }}
- name: S3에 업로드
run: aws deploy push \
--application-name "${{ env.AWS_CODE_DEPLOY_APPLICATION }}" \
--ignore-hidden-files \
--s3-location "s3://${{ env.AWS_S3_BUCKET }}/${{ env.PROJECT_NAME }}/${{ env.DIVISION }}/${{ github.sha }}.zip" \
--source "${{ env.PROJECT_NAME }}-${{ env.DIVISION }}-${{ github.sha }}.zip"
cd deploy
zip -r ../${{ env.PROJECT_NAME }}-${{ env.DIVISION }}-${{ github.sha }}.zip .
cd ..
- name: AWS credential 설정
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.DEVSERVER_CICD_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.DEVSERVER_CICD_SECRET_KEY }}
- name: S3에 업로드
run: aws s3 cp \
"${{ env.PROJECT_NAME }}-${{ env.DIVISION }}-${{ github.sha }}.zip" \
"s3://${{ env.AWS_S3_BUCKET }}/${{ env.PROJECT_NAME }}/${{ env.DIVISION }}/${{ github.sha }}.zip"
🧰 Tools
🪛 actionlint (1.7.7)

60-60: the runner of "aws-actions/configure-aws-credentials@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)

[error] 58-58: trailing spaces

(trailing-spaces)


[error] 65-65: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
In .github/workflows/deploy-admin.yml around lines 55 to 72, the current
workflow creates a ZIP file and then uses 'aws deploy push --source <zipfile>',
which causes double compression because 'aws deploy push' expects a directory,
not a ZIP file. To fix this, replace the 'aws deploy push' step with an 'aws s3
cp' command to upload the ZIP file directly to the S3 bucket, and then modify
the deployment step to use 'create-deployment' referencing the uploaded S3
object instead of pushing again.

- name: EC2에 배포
run: |
aws deploy create-deployment \
--application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} \
--s3-location bucket=${{ env.AWS_S3_BUCKET }},key=${{ env.PROJECT_NAME }}/${{ env.DIVISION }}/${{ github.sha }}.zip,bundleType=zip
57 changes: 0 additions & 57 deletions .github/workflows/dev.yml

This file was deleted.

20 changes: 20 additions & 0 deletions appspec-admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/spring-github-action
overwrite: yes

permissions:
- object: /
owner: ubuntu
group: ubuntu

hooks:
AfterInstall:
- location: scripts/stop-admin.sh
timeout: 60
ApplicationStart:
- location: scripts/start-admin.sh
timeout: 60
21 changes: 14 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ subprojects {
group = rootProject.group
version = rootProject.version

// 실행 모듈만 따로 정의
def applicationModules = ['application-admin', 'application-user']

if (applicationModules.contains(project.name)) {
// 실제 Service 실행 모듈
apply plugin: 'org.springframework.boot'
bootJar { enabled = true }
jar { enabled = false }
} else {
// 라이브러리/설정/도메인 전용 모듈
bootJar { enabled = false }
jar { enabled = true }
}

repositories {
mavenCentral()
}
Expand All @@ -43,11 +57,4 @@ subprojects {
test {
useJUnitPlatform()
}

bootJar {
enabled = false
}
jar {
enabled = true
}
}
9 changes: 7 additions & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
bootJar { enabled = false }
jar { enabled = true }
jar {
enabled = true
}
bootJar {
enabled = false
}


dependencies {
}

This file was deleted.

25 changes: 25 additions & 0 deletions scripts/start-admin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

REPOSITORY="/home/ubuntu/spring-github-action"
cd $REPOSITORY

APP_NAME=application-admin
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep '.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME

START_LOG="$REPOSITORY/start.log"
ERROR_LOG="$REPOSITORY/error.log"
APP_LOG="$REPOSITORY/application.log"

$ chmod 666 "$START_LOG"
$ chmod 666 "$ERROR_LOG"
$ chmod 666 "$APP_LOG"

SERVICE_PID=$(pgrep -f ${APP_NAME}.*.jar) # 실행중인 Spring 서버의 PID
NOW=$(date +%c)


echo "[$NOW] > $JAR_PATH 실행" >> $START_LOG
nohup java -Xms256m -Xmx512m -XX:+UseG1GC -jar $JAR_PATH --spring.profiles.active=admin > $APP_LOG 2> $ERROR_LOG &

echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG
Comment on lines +18 to +25
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

새 PID 로깅 누락

admin 스크립트 역시 기동 후 $! 로 새 PID 를 기록해야 합니다.

-SERVICE_PID=$(pgrep -f ${APP_NAME}.*.jar)
 ...
-nohup java -Xms256m -Xmx512m -XX:+UseG1GC -jar $JAR_PATH --spring.profiles.active=admin > $APP_LOG 2> $ERROR_LOG &
-
-echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG
+nohup java -Xms256m -Xmx512m -XX:+UseG1GC -jar "$JAR_PATH" --spring.profiles.active=admin \
+  >> "$APP_LOG" 2>> "$ERROR_LOG" &
+NEW_PID=$!
+echo "[$NOW] > 서비스 PID: $NEW_PID" >> "$START_LOG"
📝 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
SERVICE_PID=$(pgrep -f ${APP_NAME}.*.jar) # 실행중인 Spring 서버의 PID
NOW=$(date +%c)
echo "[$NOW] > $JAR_PATH 실행" >> $START_LOG
nohup java -Xms256m -Xmx512m -XX:+UseG1GC -jar $JAR_PATH --spring.profiles.active=admin > $APP_LOG 2> $ERROR_LOG &
echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG
# (remove the old pgrep-based PID lookup)
# SERVICE_PID=$(pgrep -f ${APP_NAME}.*.jar) # ← removed
NOW=$(date +%c)
echo "[$NOW] > $JAR_PATH 실행" >> $START_LOG
nohup java -Xms256m -Xmx512m -XX:+UseG1GC \
-jar "$JAR_PATH" --spring.profiles.active=admin \
>> "$APP_LOG" 2>> "$ERROR_LOG" &
NEW_PID=$!
echo "[$NOW] > 서비스 PID: $NEW_PID" >> $START_LOG
🤖 Prompt for AI Agents
In scripts/start-admin.sh around lines 18 to 25, the script logs the service PID
before starting the Java process, so it does not capture the new PID of the
started service. Modify the script to capture the new PID immediately after
launching the Java process using $! and then log this new PID to the START_LOG
file to accurately reflect the running service's PID.

25 changes: 25 additions & 0 deletions scripts/start-user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

REPOSITORY="/home/ubuntu/spring-github-action"
cd $REPOSITORY

APP_NAME=application-admin
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

APP_NAME 오타 – admin 모듈을 기동하게 됨

user 서비스용 스크립트에서 admin 이름을 사용하고 있습니다.

-APP_NAME=application-admin
+APP_NAME=application-user
🤖 Prompt for AI Agents
In scripts/start-user.sh at line 6, the APP_NAME variable is incorrectly set to
"application-admin" which starts the admin module instead of the user service.
Change the value of APP_NAME to the correct user service module name to ensure
the script starts the intended service.

JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep '.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME

START_LOG="$REPOSITORY/start.log"
ERROR_LOG="$REPOSITORY/error.log"
APP_LOG="$REPOSITORY/application.log"

$ chmod 666 $START_LOG
$ chmod 666 ERROR_LOG
$ chmod 666 APP_LOG
Comment on lines +14 to +16
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

chmod 명령어 문법 오류
기존 리뷰와 동일한 문제입니다.

-$ chmod 666 $START_LOG
-$ chmod 666 ERROR_LOG
-$ chmod 666 APP_LOG
+chmod 666 "$START_LOG"
+chmod 666 "$ERROR_LOG"
+chmod 666 "$APP_LOG"
📝 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
$ chmod 666 $START_LOG
$ chmod 666 ERROR_LOG
$ chmod 666 APP_LOG
chmod 666 "$START_LOG"
chmod 666 "$ERROR_LOG"
chmod 666 "$APP_LOG"
🤖 Prompt for AI Agents
In scripts/start-user.sh around lines 14 to 16, the chmod commands have a syntax
error because ERROR_LOG and APP_LOG variables are missing the $ prefix. Fix this
by adding $ before ERROR_LOG and APP_LOG to correctly reference the variables as
$ERROR_LOG and $APP_LOG.


SERVICE_PID=$(pgrep -f ${APP_NAME}.*.jar) # 실행중인 Spring 서버의 PID
NOW=$(date +%c)


echo "[$NOW] > $JAR_PATH 실행" >> $START_LOG
nohup java -Xms256m -Xmx512m -XX:+UseG1GC -jar $JAR_PATH --spring.profiles.active=user > $APP_LOG 2> $ERROR_LOG &

echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG
22 changes: 22 additions & 0 deletions scripts/stop-admin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

REPOSITORY=/home/ubuntu/spring-github-action
cd $REPOSITORY
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

cd 실패 시 즉시 종료 처리 필요

cd $REPOSITORY 가 실패하면 이후 모든 명령이 잘못된 경로에서 실행됩니다. 실패 여부를 체크해 스크립트를 종료하도록 수정해 주세요.

-cd $REPOSITORY
+cd "$REPOSITORY" || { echo "디렉터리 이동 실패"; exit 1; }
📝 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
cd $REPOSITORY
cd "$REPOSITORY" || { echo "디렉터리 이동 실패"; exit 1; }
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 4-4: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

🤖 Prompt for AI Agents
In scripts/stop-admin.sh at line 4, the script changes directory to $REPOSITORY
without checking if the command succeeds. Modify the script to check the exit
status of the cd command and immediately exit the script if cd fails, preventing
subsequent commands from running in the wrong directory.


APP_NAME=application-admin
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep '.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME
STOP_LOG="$REPOSITORY/stop.log"

$ chmod 666 "$STOP_LOG"

CURRENT_PID=$(pgrep -f ${APP_NAME}.*.jar)

if [ -z $CURRENT_PID ]
then
echo "서비스 NouFound" >> $STOP_LOG
else
echo "> kill -15 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi
22 changes: 22 additions & 0 deletions scripts/stop-user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

REPOSITORY=/home/ubuntu/spring-github-action
cd $REPOSITORY

APP_NAME=application-admin
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

잘못된 APP_NAME 지정

user 서비스 스크립트에서 application-admin 을 사용하고 있습니다.

-APP_NAME=application-admin
+APP_NAME=application-user
🤖 Prompt for AI Agents
In scripts/stop-user.sh at line 6, the APP_NAME is incorrectly set to
'application-admin' which is not the correct service name for the user service.
Change the APP_NAME variable to the correct user service name to ensure the
script targets the right application.

JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep '.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME
STOP_LOG="$REPOSITORY/stop.log"

$ chmod 666 STOP_LOG
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

chmod 문법 오류 및 변수 미사용

  1. $ chmod 로 명령이 실패합니다.
  2. 변수 대신 문자열 STOP_LOG 를 사용하고 있습니다.
-$ chmod 666 STOP_LOG
+chmod 666 "$STOP_LOG"
🤖 Prompt for AI Agents
In scripts/stop-user.sh at line 11, the chmod command is incorrectly prefixed
with a dollar sign and uses the literal string STOP_LOG instead of the variable.
Remove the dollar sign before chmod and replace the string STOP_LOG with the
appropriate variable name that holds the log file path to fix the syntax error
and correctly reference the variable.


CURRENT_PID=$(pgrep -f ${APP_NAME}.*.jar)

if [ -z $CURRENT_PID ]
then
echo "서비스 NouFound" >> $STOP_LOG
Comment on lines +15 to +17
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

PID 체크 구문에 따옴표 필요 + 오타

[ -z "$CURRENT_PID" ] 로 수정하고, 오타 NouFound 도 함께 고쳐 주세요.

-if [ -z $CURRENT_PID ]
-then
-  echo "서비스 NouFound" >> $STOP_LOG
+if [ -z "$CURRENT_PID" ]; then
+  echo "서비스 NotFound" >> "$STOP_LOG"
📝 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 [ -z $CURRENT_PID ]
then
echo "서비스 NouFound" >> $STOP_LOG
if [ -z "$CURRENT_PID" ]; then
echo "서비스 NotFound" >> "$STOP_LOG"
🤖 Prompt for AI Agents
In scripts/stop-user.sh around lines 15 to 17, the PID check condition lacks
quotes around the variable, which can cause errors if the variable is empty or
contains spaces. Update the condition to use quotes like [ -z "$CURRENT_PID" ].
Also, fix the typo in the echo statement by changing "서비스 NouFound" to the
correct spelling.

else
echo "> kill -15 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi