File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 &
You can’t perform that action at this time.
0 commit comments