-
Notifications
You must be signed in to change notification settings - Fork 12
46 lines (38 loc) · 1.05 KB
/
CD.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
name: CD
on:
push:
branches: [ "main" ]
jobs:
CD:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
cache: maven
- name: Build The Application
run: mvn -B -f pom.xml clean install -Dmaven.test.skip=true
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/remote.key
chmod 600 ~/.ssh/remote.key
cat >>~/.ssh/config <<END
Host remote
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/remote.key
StrictHostKeyChecking no
END
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
- name: Deploy The Application
run: |
ssh remote 'sudo rm -rf /api/java-api.jar'
scp target/java-api.jar remote:/api/java-api.jar