Skip to content

Commit

Permalink
Merge pull request #28 from Tave-13th-Project-Team-4-Fiurinee/feature…
Browse files Browse the repository at this point in the history
…/ci-cd

chore: ci-cd 수정
  • Loading branch information
qormoon authored Jun 24, 2024
2 parents 16090b6 + da165fd commit 92b81f7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/script/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# 현재 실행 중인 JAR 프로세스를 찾고 종료합니다.
CURRENT_PID=$(pgrep -f .jar)
echo "$CURRENT_PID"
if [ -z $CURRENT_PID ]; then
echo "no process"
else
echo "kill $CURRENT_PID"
kill -9 $CURRENT_PID
sleep 3
fi

# 새로운 JAR 파일의 경로를 설정하고 실행 권한을 부여합니다.
JAR_PATH="/home/ec2-user/cicd/*.jar"
echo "jar path : $JAR_PATH"
chmod +x $JAR_PATH

# 새로운 JAR 파일을 백그라운드에서 실행합니다.
nohup java -jar $JAR_PATH > /dev/null 2> /dev/null < /dev/null &
echo "jar file deploy success"
35 changes: 35 additions & 0 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,41 @@ jobs:
run: docker push qormoon/fiurinee_docker


# 빌드된 JAR 파일을 원격 서버에 복사합니다.
- name: Copy jar file to remote
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_SSH_KEY }}
source: "./build/libs/*.jar"
target: "/home/ec2-user/cicd"
strip_components: 2


# 배포 스크립트를 원격 서버에 복사합니다.
- name: Copy deploy script file to remote
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_SSH_KEY }}
source: ".github/scripts/deploy.sh"
target: "/home/ec2-user/cicd"

# 배포 스크립트를 원격 서버에서 실행합니다.
- name: Execute deploy script
uses: appleboy/ssh-action@master
with:
username: ec2-user
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_SSH_KEY }}
script_stop: true
script: |
chmod +x /home/ec2-user/cicd/deploy.sh
sh /home/ec2-user/cicd/deploy.sh
# # 배포
# - name: Deploy
Expand Down

0 comments on commit 92b81f7

Please sign in to comment.