Skip to content

Commit b6b5cfe

Browse files
chore: add test server deployment workflow for port 8081
1 parent f3f6892 commit b6b5cfe

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/deploy-test.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Java CI/CD - Test Server (Port 8081)
2+
3+
on:
4+
push:
5+
branches: [ "feature/apple-login-split" ] # 이 브랜치에 푸시할 때만 작동
6+
7+
jobs:
8+
build-and-deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v4
16+
with:
17+
java-version: '17'
18+
distribution: 'temurin'
19+
20+
- name: Grant execute permission for gradlew
21+
run: chmod +x gradlew
22+
23+
- name: Build with Gradle
24+
run: ./gradlew clean build -x test
25+
26+
# 1. 빌드된 JAR 파일을 EC2로 전송
27+
- name: Copy JAR to EC2
28+
uses: appleboy/scp-action@v0.1.7
29+
with:
30+
host: ${{ secrets.EC2_HOST }}
31+
username: ${{ secrets.EC2_USER }}
32+
key: ${{ secrets.EC2_SSH_KEY }}
33+
source: "build/libs/NITROGEN-0.0.1-SNAPSHOT.jar"
34+
target: "~/app/Nitrogen_Server/build/libs"
35+
strip_components: 2
36+
37+
# 2. 서버에 접속해서 8081 서버만 교체
38+
- name: Execute Remote SSH Commands
39+
uses: appleboy/ssh-action@v1.0.3
40+
with:
41+
host: ${{ secrets.EC2_HOST }}
42+
username: ${{ secrets.EC2_USER }}
43+
key: ${{ secrets.EC2_SSH_KEY }}
44+
script: |
45+
cd ~/app/Nitrogen_Server/build/libs
46+
47+
# 8081 포트를 사용 중인 프로세스만 종료 (운영 서버 8080은 유지)
48+
sudo fuser -k 8081/tcp || true
49+
50+
# 불필요한 파일 삭제
51+
find . -name "*-plain.jar" -delete
52+
53+
# 테스트 서버 실행 (포트 8081, 테스트용 yml 사용, 로그 파일 분리)
54+
nohup java -jar NITROGEN-0.0.1-SNAPSHOT.jar \
55+
--spring.config.location=file:./application-test.yml \
56+
--server.port=8081 \
57+
> nohup_dev.out 2>&1 &

0 commit comments

Comments
 (0)