-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (54 loc) · 1.79 KB
/
deploy.yml
File metadata and controls
64 lines (54 loc) · 1.79 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Deploy to EC2
on:
push:
branches: [ develop ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew bootJar -x test
- name: Copy jar to EC2
run: |
echo "${{ secrets.EC2_SSH_KEY }}" > key.pem
chmod 600 key.pem
rsync -avz -e "ssh -i key.pem -o StrictHostKeyChecking=no" \
build/libs/server-0.0.1-SNAPSHOT.jar \
ubuntu@${{ secrets.EC2_HOST }}:/home/ubuntu/app.jar
rm -f key.pem
- name: Restart application
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
sudo fuser -k 8080/tcp || true
nohup java -jar -Dspring.profiles.active=prod ~/app.jar > ~/app.log 2>&1 &
sleep 5
echo "Server started"
- name: Notify Discord on success
if: success()
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: success
title: "배포 성공 🎉"
description: "develop 브랜치 배포가 완료되었습니다."
- name: Notify Discord on failure
if: failure()
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: failure
title: "배포 실패 ❌"
description: "배포 중 오류가 발생했습니다."