Skip to content

Merge branch 'service-catalog' of https://github.com/RamziHaddad/proj… #8

Merge branch 'service-catalog' of https://github.com/RamziHaddad/proj…

Merge branch 'service-catalog' of https://github.com/RamziHaddad/proj… #8

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 # Création du JAR exécutable
- name: Run Tests with Maven
run: |
cd catalog/catalog-service/
mvn test
- name: Archive JAR Artifact
uses: actions/upload-artifact@v3
with:
name: service-catalog.jar
path: catalog/catalog-service/target/*-runner.jar # Chemin vers le JAR généré
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download JAR Artifact
uses: actions/download-artifact@v3
with:
name: service-catalog.jar
path: ./
- name: Deploy JAR to VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOYMENT_MACHINE_IP }} # Adresse IP du VPS
username: ${{ secrets.DEPLOYMENT_MACHINE_USER }} # Nom d'utilisateur SSH
password: ${{ secrets.DEPLOYMENT_MACHINE_USER_PSW }} # Mot de passe de l'utilisateur
script: |
mkdir -p ~/service-catalog
scp service-catalog.jar ${{ secrets.DEPLOYMENT_MACHINE_USER }}@${{ secrets.DEPLOYMENT_MACHINE_IP }}:~/service-catalog/service-catalog.jar
pkill -f 'java.*service-catalog.jar' || true
nohup java -jar ~/service-catalog/service-catalog.jar --server.port=8082 > ~/service-catalog/app.log 2>&1 &