diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 62407e46..2acaa278 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,10 @@ jobs: run: ./gradlew clean build - name: Copy jar - run: cp ./build/libs/*.jar ./$GITHUB_SHA.jar + run: cp ./build/libs/*.jar ./deploy/$GITHUB_SHA.jar + + - name: Make zip file + run: zip -r -qq ./$GITHUB_SHA.zip . - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 @@ -41,7 +44,7 @@ jobs: aws-region: ap-northeast-2 - name: Upload to S3 - run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.jar s3://team3rdparty-bucket/deploy/$GITHUB_SHA.jar + run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://team3rdparty-bucket/deploy/$GITHUB_SHA.zip - name: Deploy run: | @@ -52,6 +55,5 @@ jobs: --deployment-config-name CodeDeployDefault.AllAtOnce \ --deployment-group-name ticketing-group \ --file-exists-behavior OVERWRITE \ - --s3-location bucket=team3rdparty-bucket,bundleType=zip,key=deploy/$GITHUB_SHA.jar \ + --s3-location bucket=team3rdparty-bucket,bundleType=zip,key=deploy/$GITHUB_SHA.zip \ --target-instances 'tagFilters=[{Key=Name,Value=team3-ticket,Type=KEY_AND_VALUE}]' - diff --git a/appspec.yml b/appspec.yml index 5d451411..0fe0f62e 100644 --- a/appspec.yml +++ b/appspec.yml @@ -1,8 +1,14 @@ version: 0.0 os: linux files: - - source: /*.jar - destination: /home/ubuntu/deploy/ticketing.jar + - source: / + destination: /home/ubuntu/app/deploy + +permissions: + - object: / + pattern: "**" + owner: ubuntu + group: ubuntu hooks: ApplicationStart: diff --git a/scripts/deploy.sh b/scripts/deploy.sh index a43554d5..25c5f12b 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,19 +1,21 @@ #!/bin/bash # 변수 설정 -build_jar=$(ls /home/ubuntu/deploy/ticketing.jar) -jar_name=$(basename "$build_jar") -deploy_log=/home/ubuntu/deploy/deloy.log +BUILD_JAR=$(ls /home/ubuntu/app/deploy/build/libs/*.jar) +JAR_NAME=$(basename "$BUILD_JAR") +DEPLOY_PATH=/home/ubuntu/app/deploy/ +DEPLOY_LOG=$DEPLOY_PATH/deploy.log -echo ">>> 현재 실행중인 애플리케이션 pid 확인" >> $deploy_log -CURRENT_PID=$(pgrep -f "$jar_name") +echo ">>> 현재 실행중인 애플리케이션 pid 확인" >> $DEPLOY_LOG +CURRENT_PID=$(pgrep -f "$JAR_NAME") if [ -z "$CURRENT_PID" ] then - echo ">>> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." >> $deploy_log + echo ">>> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." >> $DEPLOY_LOG else kill -9 "$CURRENT_PID" fi -echo ">>> DEPLOY_JAR 배포" >> $deploy_log -nohup java -jar "$build_jar" --spring.profiles.active=prod \ No newline at end of file +DEPLOY_JAR=$DEPLOY_PATH$JAR_NAME +echo ">>> DEPLOY_JAR 배포" >> $DEPLOY_LOG +nohup java -jar "$DEPLOY_JAR" --spring.profiles.active=prod \ No newline at end of file