-
Notifications
You must be signed in to change notification settings - Fork 5
68 lines (56 loc) · 1.92 KB
/
catalog-service-ci-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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: CI/CD Pipeline
on:
push:
branches:
- service-catalog
pull_request:
branches:
- service-catalog
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
- name: Build with Maven
run: |
cd catalog/catalog-service/
mvn clean package -Dquarkus.package.type=uber-jar
- name: Archive JAR Artifact
uses: actions/upload-artifact@v3
with:
name: service-catalog.jar
path: catalog/catalog-service/target/*-runner.jar
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Install sshpass
run: sudo apt-get install -y sshpass
- name: Download JAR Artifact
uses: actions/download-artifact@v3
with:
name: service-catalog.jar
path: ./
- name: Add Server to Known Hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.DEPLOYMENT_MACHINE_IP }} >> ~/.ssh/known_hosts
- name: Transfer JAR to VPS
run: |
sshpass -p "${{ secrets.DEPLOYMENT_MACHINE_USER_PSW }}" scp ./service-catalog.jar ${{ secrets.DEPLOYMENT_MACHINE_USER }}@${{ secrets.DEPLOYMENT_MACHINE_IP }}:~/service-catalog/service-catalog.jar
- name: Deploy JAR to VPS
uses: appleboy/ssh-action@v0.1.2 # Mise à jour de la version
with:
host: ${{ secrets.DEPLOYMENT_MACHINE_IP }}
username: ${{ secrets.DEPLOYMENT_MACHINE_USER }}
password: ${{ secrets.DEPLOYMENT_MACHINE_USER_PSW }}
script: |
mkdir -p ~/service-catalog
pkill -f 'java.*service-catalog.jar' || true
nohup java -jar ~/service-catalog/service-catalog.jar --server.port=8082 > ~/service-catalog/app.log 2>&1 &