Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #271 from GSM-MSG/codedeploy
Browse files Browse the repository at this point in the history
Codedeploy
  • Loading branch information
shk0625 authored Jan 21, 2024
2 parents 5edee71 + 6d6529f commit 366c432
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/GCMS-CD.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: GCMS-CD
on:
push:
branches: [ "develop" ]
branches: [ "develop", "codedeploy" ]

env:
S3_BUCKET_NAME: gcms-deploy-bucket
AWS_REGION: ap-northeast-2
PROJECT_NAME: Gcms-Sever

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

files:
- source: /
destination: /home/ec2-user/
overwrite: yes

permissions:
- object: /home/ec2-user/
pattern: "**"
owner: ec2-user
group: ec2-user

hooks:
ApplicationStart:
- location: deploy.sh
timeout: 60
runas: ec2-user
25 changes: 25 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
REPOSITORY=/home/ec2-user
PROJECT_NAME=Gcms-Sever
JAR_PATH=$REPOSITORY/$PROJECT_NAME/GCMS-Backend/build/libs/gcms-0.0.1-SNAPSHOT.jar

cd $REPOSITORY/$PROJECT_NAME/

echo "> Git Pull"
git pull origin develop

echo "> Project Build"
./gradlew clean GCMS-Backend:build

CURRENT_PID=$(lsof -i tcp:80)
if [ -z "$CURRENT_PID" ]; then
echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다."
else
echo "> kill -9 $CURRENT_PID"
kill -9 $CURRENT_PID
sleep 5
fi

echo "> 애플리케이션 배포"
JAR_NAME=$(ls -tr $JAR_PATH | tail -n 1)
echo "> JAR NAME: $JAR_NAME"
nohup java -jar $JAR_NAME --logging.file.path=/home/ec2-user/ --logging.level.org.hibernate.SQL=DEBUG >> /home/ec2-user/deploy.log 2>/home/ec2-user/deploy_err.log &

0 comments on commit 366c432

Please sign in to comment.