Update cd-dev.yml 디버깅 #13
This file contains 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
name: CD - Deploy to Production Server | |
on: | |
push: | |
branches: [ "dev" ] | |
env: | |
AWS_REGION: ap-northeast-2 | |
S3_BUCKET_NAME: meerket-bucket | |
CODE_DEPLOY_APPLICATION_NAME: meerket-dev | |
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: meerket-deployment-group | |
permissions: write-all | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
# 1) 기본 체크아웃 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# 2) JDK 17 셋팅 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# 3) gradlew 권한 설정 | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./meerket/gradlew | |
# 4) gradle 빌드 | |
- name: Build with Gradle | |
working-directory: ./meerket | |
run: ./gradlew clean build -x test --no-daemon --info | |
# 5) 빌드 결과 확인 | |
- name: Verify JAR file | |
run: | | |
echo "Checking build directory..." | |
ls -al ./meerket/meerket-application/build/libs | |
echo "Verifying Spring Boot loader in JAR file..." | |
jar tf ./meerket/meerket-application/build/libs/*.jar | grep "org/springframework/boot/loader" || echo "Spring Boot loader not found" | |
# 6) JAR 파일 크기 확인 | |
- name: Check JAR File Size | |
run: | | |
echo "JAR file size:" | |
du -h ./meerket/meerket-application/build/libs/*.jar || echo "JAR file not found" | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
environment: production | |
needs: [ build ] | |
steps: | |
# 1) 기본 체크아웃 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# 2) JDK 17 셋팅 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# 3) gradlew 권한 설정 | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./meerket/gradlew | |
# 4) S3 업로드 확인 | |
- name: Upload to AWS S3 | |
run: | | |
echo "Navigating to build directory..." | |
cd meerket/meerket-application/build/libs | |
ls -al | |
echo "Uploading to S3..." | |
aws deploy push \ | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | |
--ignore-hidden-files \ | |
--s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \ | |
--source . | |
echo "Verifying S3 bucket contents..." | |
aws s3 ls s3://${{ env.S3_BUCKET_NAME }}/ | |
# 5) AWS EC2에 Deploy | |
- name: Deploy to AWS EC2 from S3 | |
run: | | |
echo "Starting deployment to EC2..." | |
aws deploy create-deployment \ | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \ | |
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip | |
echo "Checking deployment status..." | |
aws deploy list-deployments --application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | |
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} --query 'deployments' --output json |