-
Notifications
You must be signed in to change notification settings - Fork 4
45 lines (37 loc) · 1.24 KB
/
dev-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: 개발 서버 배포
on:
push:
branches:
- dev
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: JDK 17 설정
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: gradlew 실행 권한 부여
run: chmod +x gradlew
- name: JAR 빌드
run: ./gradlew clean build
- name: JAR를 EC2로 전송
env:
PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }}
HOST: ${{ secrets.DEV_EC2_HOST }}
USER: ${{ secrets.DEV_EC2_USER }}
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
scp -o StrictHostKeyChecking=no -i private_key mono/build/libs/*.jar ${USER}@${HOST}:~/app.jar
- name: EC2에서 JAR 실행
env:
PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }}
HOST: ${{ secrets.DEV_EC2_HOST }}
USER: ${{ secrets.DEV_EC2_USER }}
run: |
ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} << EOF
pkill -f 'java -jar app.jar --spring.profiles.active=dev' || true
nohup java -jar app.jar --spring.profiles.active=dev > app.log 2>&1 &
EOF