Skip to content

Commit

Permalink
Update search-ci-cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeineb2001 authored Dec 13, 2024
1 parent d5f1103 commit fef61f6
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/search-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,46 @@ jobs:
- name: Verify if the correct JAR file exists
run: |
ls search/target/service-search.jar || (echo "JAR file not found!" && exit 1)
- 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 ./search/target/service-search.jar \
${{ secrets.DEPLOYMENT_MACHINE_USER }}@${{ secrets.DEPLOYMENT_MACHINE_IP }}:~/service-search/service-search.jar
- name: Verify if the JAR file exists on the VPS
run: |
sshpass -p "${{ secrets.DEPLOYMENT_MACHINE_USER_PSW }}" ssh ${{ secrets.DEPLOYMENT_MACHINE_USER }}@${{ secrets.DEPLOYMENT_MACHINE_IP }} \
"ls -l ~/service-search/service-search.jar"
- name: Show system resources usage after file transfer
run: |
sshpass -p "${{ secrets.DEPLOYMENT_MACHINE_USER_PSW }}" ssh ${{ secrets.DEPLOYMENT_MACHINE_USER }}@${{ secrets.DEPLOYMENT_MACHINE_IP }} \
"df -h && free -h && top -bn1 | grep 'Cpu(s)'"
- name: Deploy JAR to VPS
uses: appleboy/ssh-action@v0.1.2
with:
host: ${{ secrets.DEPLOYMENT_MACHINE_IP }}
username: ${{ secrets.DEPLOYMENT_MACHINE_USER }}
password: ${{ secrets.DEPLOYMENT_MACHINE_USER_PSW }}
script: |
sleep 10
echo "Starting Spring Boot service..."
cd ~/service-search
nohup java -jar service-search.jar --server.port=8089 > service-search.log 2>&1 &
echo "Spring Boot service deployed successfully!"
sleep 30
echo "Performing health check..."
curl -X 'GET' 'http://localhost:8089/actuator/health' -H 'accept: application/json' || (echo "Service health check failed!" && exit 1)
echo "Service deployed and healthy!"
tail -n 50 ~/service-search/service-search.log

0 comments on commit fef61f6

Please sign in to comment.