-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (48 loc) · 1.83 KB
/
Copy pathdeploy-develop.yml
File metadata and controls
58 lines (48 loc) · 1.83 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
name: develop CI/CD
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: get Github Repository
uses: actions/checkout@v4
- name: install JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Create resources directory if it does not exist
run: mkdir -p ./src/main/resources
- name: create application.yml
run: echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.yml
- name: test and build
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/scp-action@v0.1.7
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
source: project.jar
target: /home/ec2-user/yesable_server/tobe
- name: connect to EC2 with SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
envs: APPLICATION_PROPERTIES
script_stop: true
script: |
rm -rf /home/ec2-user/yesable_server/current
mkdir /home/ec2-user/yesable_server/current
mv /home/ec2-user/yesable_server/tobe/project.jar /home/ec2-user/yesable_server/current/project.jar
cd /home/ec2-user/yesable_server/current
sudo fuser -k -n tcp 8081 || true
nohup java -jar project.jar --spring.profiles.active=local > ~/yesable_server/logs/server.log 2>&1 &
rm -rf /home/ec2-user/yesable_server/tobe