-
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
1 parent
c49559a
commit 3fbab5c
Showing
1 changed file
with
40 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,40 @@ | ||
name: Java CI/CD with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "dev" ] | ||
pull_request: | ||
branches: [ "dev" ] | ||
|
||
jobs: | ||
deploy: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up SSH | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.EC2_KEY }}" > ~/.ssh/id_rsa | ||
chmod 400 ~/.ssh/id_rsa | ||
ssh-keyscan ${{ secrets.HOST }} >> ~/.ssh/known_hosts | ||
chmod 600 ~/.ssh/known_hosts | ||
- name: Build & Deploy | ||
run: | | ||
ssh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} ' | ||
cd /home/ubuntu && | ||
git pull && | ||
./gradlew clean build && | ||
sudo cp build/libs/spotserver-0.0.1-SNAPSHOT.jar /home/ubuntu/spotserver-0.0.1-SNAPSHOT.jar | ||
' | ||
- name: Restart Service | ||
run: | | ||
ssh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} ' | ||
# 기존 spotserver 프로세스 종료 | ||
pkill -f "spotserver-0.0.1-SNAPSHOT.jar" || true && | ||
# 새로운 spotserver 실행 | ||
nohup java -jar /home/ubuntu/spotserver-0.0.1-SNAPSHOT.jar > /home/ubuntu/nohup.out 2>&1 & | ||
' | ||