Skip to content

Commit b8ce4d6

Browse files
authored
[Docs] Create CD.yml
1 parent 7ec399e commit b8ce4d6

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/CD.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches: [ "develop" ]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-24.04
10+
11+
steps:
12+
- name: checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v4
17+
with:
18+
distribution: 'corretto'
19+
java-version: '17'
20+
21+
- name: build
22+
run: |
23+
chmod +x gradlew
24+
./gradlew build -x test
25+
26+
- name: Copy jar to EC2
27+
uses: appleboy/scp-action@v0.1.7
28+
with:
29+
host: ${{ secrets.EC2_HOST }}
30+
username: ${{ secrets.EC2_USER }}
31+
key: ${{ secrets.EC2_SSH_KEY }}
32+
source: "build/libs/*.jar"
33+
target: "/home/ubuntu/app"
34+
35+
- name: Restart app on EC2
36+
uses: appleboy/ssh-action@v0.1.10
37+
with:
38+
host: ${{ secrets.EC2_HOST }}
39+
username: ${{ secrets.EC2_USER }}
40+
key: ${{ secrets.EC2_SSH_KEY }}
41+
script: |
42+
pkill -f 'java -jar' || true
43+
nohup java -jar /home/ubuntu/app/*.jar > /home/ubuntu/app/app.log 2>&1 &

0 commit comments

Comments
 (0)