-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (45 loc) · 1.63 KB
/
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
46
47
48
49
50
51
52
53
54
55
name: Deploy to EC2
on:
push:
branches:
- master
jobs:
Deploy-Job:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Create application.yml
run: echo "${{ secrets.APPLICATION_TEST_PROPERTIES }}" > ./src/main/resources/application.yml
- name: Build and test
run: ./gradlew clean build -Dspring.profiles.active=test
- name: Rename the built file
run: mv ./build/libs/*SNAPSHOT.jar ./project.jar
- name: Copy the built file to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
source: project.jar
target: /home/ubuntu/concurrencyPrac/tobe
- name: Deploy on 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/concurrencyPrac/current
mkdir /home/ubuntu/concurrencyPrac/current
mv /home/ubuntu/concurrencyPrac/tobe/project.jar /home/ubuntu/concurrencyPrac/current/project.jar
cd /home/ubuntu/concurrencyPrac/current
sudo fuser -k -n tcp 8080 || true
nohup java -jar project.jar > ./output.log 2>&1 &
rm -rf /home/ubuntu/concurrencyPrac/tobe