-
Notifications
You must be signed in to change notification settings - Fork 0
[Release] DEV -> PROD 병합 #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9f27f1e
[CI/CD] CI/CD 전략 변경 (#5)
taek2222 70858f9
[Refactor] Dev 환경 이미지 S3 방향 전환 (#7)
taek2222 3dce7e4
[Refactor] 테스트 코드 @MockitoBean, 중복 코드 추상화 (#37)
taek2222 b2418c1
[FEAT] jacoco/SonarQubeCloud 도입 (#33)
changuii 4d1f216
[Feat] Grafana 모니터링 스택 설정 추가 (#4)
soeun2537 9abb394
[Feat] CodeDeploy 스크립트 수정 (#41)
soeun2537 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: CI/CD Build, Upload, Deploy (Dev) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ dev ] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build-and-upload: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: 21 | ||
| cache: gradle | ||
|
|
||
| - name: Create application-secret.yml | ||
| run: | | ||
| mkdir -p src/main/resources | ||
| echo "${{ secrets.DEV_SECRET_YML }}" > src/main/resources/application-secret.yml | ||
|
|
||
| - name: Create firebase-adminsdk-account.json | ||
| run: | | ||
| mkdir -p src/main/resources/firebase | ||
| echo '${{ secrets.FIREBASE_ADMINSDK_ACCOUNT_KEY }}' \ | ||
| > src/main/resources/firebase/firebase-adminsdk-account.json | ||
|
|
||
| - name: Gradle build | ||
| run: | | ||
| chmod +x ./gradlew | ||
| ./gradlew clean build | ||
|
|
||
| - name: Find executable jar | ||
| id: jar | ||
| run: | | ||
| JAR_PATH=$(find build/libs -name "*.jar" ! -name "*plain.jar" | head -n 1) | ||
| if [ -z "$JAR_PATH" ]; then | ||
| echo "No executable jar found"; exit 1; | ||
| fi | ||
| echo "jar_path=$JAR_PATH" >> "$GITHUB_OUTPUT" | ||
| echo "jar_name=$(basename "$JAR_PATH")" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create deploy bundle | ||
| id: bundle | ||
| run: | | ||
| mkdir -p deploy | ||
| cp "${{ steps.jar.outputs.jar_path }}" deploy/ | ||
|
|
||
| cp infra/appspec.yml deploy/ 2>/dev/null || true | ||
| cp infra/*.sh deploy/ 2>/dev/null || true | ||
|
|
||
| cd deploy | ||
| ZIP_NAME="festabook-$(date +'%Y%m%d%H%M%S')-${GITHUB_SHA::7}.zip" | ||
| zip -r "$ZIP_NAME" . | ||
| echo "zip_name=$ZIP_NAME" >> "$GITHUB_OUTPUT" | ||
| echo "zip_path=$(pwd)/$ZIP_NAME" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-region: ${{ secrets.AWS_DEPLOY_REGION }} | ||
| role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }} | ||
| role-session-name: festabook-ci-cd | ||
|
|
||
| - name: Upload artifact to S3 | ||
| run: | | ||
| aws s3 cp "${{ steps.bundle.outputs.zip_path }}" \ | ||
| "s3://${{ secrets.S3_ARTIFACT_BUCKET }}/dev/builds/${{ steps.bundle.outputs.zip_name }}" | ||
|
|
||
| - name: Trigger CodeDeploy deployment | ||
| run: | | ||
| aws deploy create-deployment \ | ||
| --application-name "${{ secrets.CODEDEPLOY_APP_NAME }}" \ | ||
| --deployment-group-name "${{ secrets.CODEDEPLOY_DEPLOYMENT_GROUP_DEV }}" \ | ||
| --s3-location bucket=${{ secrets.S3_ARTIFACT_BUCKET }},bundleType=zip,key=dev/builds/${{ steps.bundle.outputs.zip_name }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: CI/CD Build, Upload, Deploy (Prod) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ prod ] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build-and-upload: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: 21 | ||
| cache: gradle | ||
|
|
||
| - name: Create application-secret.yml | ||
| run: | | ||
| mkdir -p src/main/resources | ||
| echo "${{ secrets.PROD_SECRET_YML }}" > src/main/resources/application-secret.yml | ||
|
|
||
| - name: Create firebase-adminsdk-account.json | ||
| run: | | ||
| mkdir -p src/main/resources/firebase | ||
| echo '${{ secrets.FIREBASE_ADMINSDK_ACCOUNT_KEY }}' \ | ||
| > src/main/resources/firebase/firebase-adminsdk-account.json | ||
|
|
||
| - name: Gradle build | ||
| run: | | ||
| chmod +x ./gradlew | ||
| ./gradlew clean build | ||
|
|
||
| - name: Find executable jar | ||
| id: jar | ||
| run: | | ||
| JAR_PATH=$(find build/libs -name "*.jar" ! -name "*plain.jar" | head -n 1) | ||
| if [ -z "$JAR_PATH" ]; then | ||
| echo "No executable jar found"; exit 1; | ||
| fi | ||
| echo "jar_path=$JAR_PATH" >> "$GITHUB_OUTPUT" | ||
| echo "jar_name=$(basename "$JAR_PATH")" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create deploy bundle | ||
| id: bundle | ||
| run: | | ||
| mkdir -p deploy | ||
| cp "${{ steps.jar.outputs.jar_path }}" deploy/ | ||
|
|
||
| cp infra/appspec.yml deploy/ 2>/dev/null || true | ||
| cp infra/*.sh deploy/ 2>/dev/null || true | ||
|
|
||
| cd deploy | ||
| ZIP_NAME="festabook-$(date +'%Y%m%d%H%M%S')-${GITHUB_SHA::7}.zip" | ||
| zip -r "$ZIP_NAME" . | ||
| echo "zip_name=$ZIP_NAME" >> "$GITHUB_OUTPUT" | ||
| echo "zip_path=$(pwd)/$ZIP_NAME" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-region: ${{ secrets.AWS_DEPLOY_REGION }} | ||
| role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }} | ||
| role-session-name: festabook-ci-cd | ||
|
|
||
| - name: Upload artifact to S3 | ||
| run: | | ||
| aws s3 cp "${{ steps.bundle.outputs.zip_path }}" \ | ||
| "s3://${{ secrets.S3_ARTIFACT_BUCKET }}/prod/builds/${{ steps.bundle.outputs.zip_name }}" | ||
|
|
||
| - name: Trigger CodeDeploy deployment | ||
| run: | | ||
| aws deploy create-deployment \ | ||
| --application-name "${{ secrets.CODEDEPLOY_APP_NAME }}" \ | ||
| --deployment-group-name "${{ secrets.CODEDEPLOY_DEPLOYMENT_GROUP_PROD }}" \ | ||
| --s3-location bucket=${{ secrets.S3_ARTIFACT_BUCKET }},bundleType=zip,key=prod/builds/${{ steps.bundle.outputs.zip_name }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| name: Backend CI Test | ||
| name: CI Test | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - backend-prod | ||
| - backend-dev | ||
| - prod | ||
| - dev | ||
|
|
||
| jobs: | ||
| Run-PR-Test: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| contents: write | ||
| pull-requests: write | ||
| checks: write | ||
|
|
||
|
|
@@ -24,33 +24,49 @@ jobs: | |
| java-version: '21' | ||
| distribution: 'temurin' | ||
|
|
||
| - name: Cache SonarQube packages | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.sonar/cache | ||
| key: ${{ runner.os }}-sonar | ||
| restore-keys: ${{ runner.os }}-sonar | ||
|
|
||
| - name: Gradle cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.gradle/caches | ||
| ~/.gradle/wrapper | ||
| key: ${{ runner.os }}-gradle-${{ hashFiles('backend/**/*.gradle*', 'backend/**/gradle-wrapper.properties') }} | ||
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-gradle- | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x backend/gradlew | ||
| run: chmod +x ./gradlew | ||
|
|
||
| - name: Create firebase-adminsdk-account.json | ||
| run: | | ||
| mkdir -p backend/src/main/resources/firebase | ||
| echo "${{ secrets.FIREBASE_ADMINSDK_ACCOUNT_KEY }}" > backend/src/main/resources/firebase/firebase-adminsdk-account.json | ||
| mkdir -p src/main/resources/firebase | ||
| echo "${{ secrets.FIREBASE_ADMINSDK_ACCOUNT_KEY }}" > src/main/resources/firebase/firebase-adminsdk-account.json | ||
|
|
||
| - name: Run Gradle Test | ||
| run: ./gradlew clean test | ||
| working-directory: backend | ||
| env: | ||
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
| run: ./gradlew clean test jacocoTestReport sonar | ||
|
|
||
| - name: Publish Unit Test Results | ||
| if: always() | ||
| uses: EnricoMi/publish-unit-test-result-action@v2 | ||
| with: | ||
| files: backend/build/test-results/test/TEST-*.xml | ||
| files: build/test-results/test/TEST-*.xml | ||
| check_name: '테스트 결과 🛠️' | ||
| check_run_annotations: 'none' | ||
| comment_mode: 'off' | ||
|
|
||
| - name: Comment coverage on PR | ||
| uses: madrapps/[email protected] | ||
| with: | ||
| paths: build/reports/jacoco/test/jacocoTestReport.xml | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| min-coverage-overall: 90 | ||
| min-coverage-changed-files: 100 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# 워크플로우 파일 조회 및 검토 cat -n .github/workflows/ci-cd-prod.ymlRepository: festabook/backend
Length of output: 3395
CodeDeploy 배포 트리거 구성이 기본 원칙을 잘 따르고 있습니다.
S3 경로를
prod/builds/로 체계적으로 분리하고, 배포 그룹도 환경별로 구분한 점은 좋은 관행입니다. 다만 현재 워크플로우에는 배포 단계의 실패를 처리하는 메커니즘이 완전히 빠져있다는 점이 아쉽습니다.구체적으로 개선이 필요한 부분:
배포 실패 시 알림 부재 - CodeDeploy 배포 명령이 실패하면 현재는 조용히 실패합니다. 실패 여부를 감지하고 팀에 알릴 수 있도록 Slack 알림이나 GitHub 체크 실패 같은 메커니즘을 추가하면, 배포 문제를 빠르게 감지할 수 있습니다.
배포 상태 확인 부재 -
aws deploy create-deployment는 배포를 트리거하기만 하고, 실제 배포가 성공적으로 완료되었는지는 확인하지 않습니다. 배포 ID를 캡처해서aws deploy wait deployment-successful같은 명령으로 완료를 대기하거나,get-deploymentAPI로 최종 상태를 확인하는 방식을 고려해보세요. 이렇게 하면 부분 실패를 감지할 수 있습니다.추가로, CodeDeploy 배포 그룹 설정 확인도 권장합니다:
이런 AWS 측 설정과 워크플로우 레벨의 모니터링을 함께 구성하면, 프로덕션 배포의 안정성을 크게 높일 수 있습니다.