Skip to content
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

Code Deploy Error Fix #51

Merged
merged 6 commits into from
Mar 24, 2024
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
18 changes: 3 additions & 15 deletions .github/workflows/cd-wordflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
cd ./src/main/resources
touch ./application.yaml
echo "${{ secrets.APPLICATION_YAML }}" > ./application.yaml
echo "${{ secrets.AWS_KEYSTORE }}" | base64 --decode > ./keystore-aws.p12
cd ../../test/resources
touch ./application.yaml
echo "${{ secrets.APPLICATION_TEST_YAML }}" > ./application.yaml
Expand All @@ -57,26 +58,13 @@ jobs:
cp ./appspec.yml ./deploy/
cp -r ./scripts ./deploy/
# 압축파일 형태로 전달
- name: Make zip file
run: zip -r ./springboot-intro-build.zip ./deploy

# CodeDeploy 파일 복사
- name: Copy CodeDeploy Files
run: |
cp ./appspec.yml ./deploy/
cp -r ./scripts ./deploy/
- name: Deliver to AWS S3
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ap-southeast-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: S3에 업로드
run: aws deploy push --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://gamemuncheol-s3/deploy --source ./deploy
run: aws deploy push --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://gamemuncheol-s3/deploy.zip --source ./deploy
- 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=$AWS_S3_BUCKET,key=cicdtest/$GITHUB_SHA.zip,bundleType=zip
run: aws deploy create-deployment --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --s3-location bucket=gamemuncheol-s3,key=deploy/springboot-intro-build.zip,bundleType=zip


run: aws deploy create-deployment --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --s3-location bucket=gamemuncheol-s3,key=deploy.zip,bundleType=zip
4 changes: 1 addition & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/bin/bash

ROOT_PATH="/home/ubuntu/spring-github-action"
JAR="$ROOT_PATH/application.jar"
JAR="$ROOT_PATH/gamemoonchul-0.0.1-SNAPSHOT.jar"

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

NOW=$(date +%c)

echo "[$NOW] $JAR 복사" >> $START_LOG
cp $ROOT_PATH/build/libs/spring-github-action-1.0.0.jar $JAR

echo "[$NOW] > $JAR 실행" >> $START_LOG
nohup java -jar $JAR > $APP_LOG 2> $ERROR_LOG &
Expand Down
4 changes: 2 additions & 2 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

ROOT_PATH="/home/ubuntu/spring-github-action"
JAR="$ROOT_PATH/application.jar"
JAR="$ROOT_PATH/gamemoonchul-0.0.1-SNAPSHOT.jar"
STOP_LOG="$ROOT_PATH/stop.log"
SERVICE_PID=$(pgrep -f $JAR) # 실행중인 Spring 서버의 PID

if [ -z "$SERVICE_PID" ]; then
echo "서비스 NouFound" >> $STOP_LOG
echo "서비스 NotFound" >> $STOP_LOG
else
echo "서비스 종료 " >> $STOP_LOG
kill "$SERVICE_PID"
Expand Down
Loading