-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (52 loc) · 1.86 KB
/
cicd.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Java CI/CD with Gradle
on:
push:
branches: [ "release" ]
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub Repository Code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Checkout SubModule Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.ACTION_TOKEN }}
submodules: true
- name: Git Submodule Update
run: |
git submodule update --remote --recursive
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build With Test
run: ./gradlew clean build
- name: Change Build File Name
run: mv ./build/libs/*SNAPSHOT.jar ./project.jar
- name: Send Build File To EC2 With SCP
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
source: project.jar
target: /home/ubuntu/Jaebichuri-Backend/tobe
- name: SSH To EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script_stop: true
script: |
rm -rf /home/ubuntu/Jaebichuri-Backend/current
mkdir /home/ubuntu/Jaebichuri-Backend/current
mv /home/ubuntu/Jaebichuri-Backend/tobe/project.jar /home/ubuntu/Jaebichuri-Backend/current/project.jar
cd /home/ubuntu/Jaebichuri-Backend/current
sudo fuser -k -n tcp 8080 || true
nohup java -jar project.jar --spring.profiles.active=dev > ./output.log 2>&1 &
rm -rf /home/ubuntu/Jaebichuri-Backend/tobe