Skip to content

Commit

Permalink
Update Deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jinseohyun1228 authored Nov 7, 2024
1 parent 960df84 commit 67c608c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ jobs:
uses: actions/setup-java@v2
with:
java-version: '21' # JDK 버전
distribution: 'temurin' # 또는 'zulu'와 같은 다른 배포도 가능
distribution: 'temurin' # 또는 'zulu'

- name: Create application properties file
run: echo "${{ secrets.APPLICATION }}" > application.properties # GitHub Secrets에 저장된 프로퍼티 작성

- name: Build with Gradle
run: |
Expand All @@ -26,20 +29,20 @@ jobs:
- name: Copy files to server
run: |
ssh -i "kwy-root.pem" ubuntu@ec2-52-79-80-3.ap-northeast-2.compute.amazonaws.com << EOF
echo "${{ secrets.SSH_KEY }}" > kwy-root.pem # SSH 키를 파일로 저장
chmod 600 kwy-root.pem # 파일 권한 설정
ssh -i kwy-root.pem ubuntu@ec2-52-79-80-3.ap-northeast-2.compute.amazonaws.com << EOF
# 서버에서 실행할 명령어
cd ~/Team11_BE # 프로젝트 디렉터리로 이동
git pull origin deploy # 배포 브랜치에서 업데이트
ps -ef | grep java | awk '{print $2}' | xargs kill -9 # 이전 Java 프로세스 종료
# 애플리케이션 프로퍼티 환경 변수 설정
export SPRING_APPLICATION_PROPERTIES=${{ secrets.APPLICATION }} # GitHub Secrets에서 가져오기
# 작성된 프로퍼티 파일 이동
cp ~/path/to/application.properties ~/Team11_BE/boomerang/ # 프로퍼티 파일 이동
nohup java -jar -Dspring.config.location=${SPRING_APPLICATION_PROPERTIES} build/libs/boomerang-0.0.1-SNAPSHOT.jar > log.txt 2>&1 & # 애플리케이션 실행
nohup java -jar -Dspring.config.location=boomerang/application.properties build/libs/boomerang-0.0.1-SNAPSHOT.jar > log.txt 2>&1 & # 애플리케이션 실행
EOF
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} # SSH 비공개 키를 GitHub Secrets에 저장해두세요.
- name: Check log file
run: |
ssh -i "kwy-root.pem" ubuntu@ec2-52-79-80-3.ap-northeast-2.compute.amazonaws.com "tail -f ~/Team11_BE/log.txt" # 로그 파일 확인
ssh -i kwy-root.pem ubuntu@ec2-52-79-80-3.ap-northeast-2.compute.amazonaws.com "tail -f ~/Team11_BE/log.txt" # 로그 파일 확인

0 comments on commit 67c608c

Please sign in to comment.