-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: master 브랜치 자동 배포 | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 프로젝트 코드를 CI 서버로 옮겨오기 | ||
uses: actions/checkout@v4 | ||
|
||
- name: JDK 21 설치 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '21' | ||
|
||
- name: 빌드로 테스트 수행 및 Jar 파일 생성 | ||
run: | | ||
./gradlew clean build | ||
mv build/libs/*SNAPSHOT.jar ./app.jar | ||
- name: 생성된 Jar 파일 EC2 서버로 전송하기 | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_KEY }} | ||
script_stop: true | ||
overwrite: true | ||
source: app.jar | ||
target: /home/ubuntu/project | ||
|
||
- name: EC2 서버에 접속하기(SSH) 및 스프링 서버 실행 | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_KEY }} | ||
script_stop: true | ||
script: | | ||
cd ./project | ||
sudo fuser -k -n tcp 8080 || true | ||
nohup java -jar app.jar > ./output.log 2>&1 & |