From 77fe8be4a623b3a84e6087ffb21e8bf353ebd818 Mon Sep 17 00:00:00 2001
From: hxuanyu <2252193204@qq.com>
Date: Mon, 4 Nov 2024 18:03:20 +0800
Subject: [PATCH] =?UTF-8?q?devops=E5=90=84=E6=AD=A5=E9=AA=A4=E4=BD=BF?=
 =?UTF-8?q?=E7=94=A8=E4=B8=AD=E6=96=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitea/workflows/build-deploy.yaml | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/.gitea/workflows/build-deploy.yaml b/.gitea/workflows/build-deploy.yaml
index 4feba64..8a09ff3 100644
--- a/.gitea/workflows/build-deploy.yaml
+++ b/.gitea/workflows/build-deploy.yaml
@@ -45,5 +45,16 @@ jobs:
           username: ${{ secrets.SERVER_USERNAME }}
           password: ${{ secrets.SERVER_PASSWORD }}
           port: ${{ secrets.SERVER_PORT }}
-          source: "target/*.jar"
-          target: "/home/tools/testActions"
+          source: target/*.jar
+          target: /home/tools/${{ var.APP_NAME }}/package
+      # 停止远程服务进程
+      - name: 使用新版jar包启动应用
+        uses: appleboy/ssh-action@master
+        with:
+          host: ${{ secrets.SERVER_HOST }}
+          username: ${{ secrets.SERVER_USERNAME }}
+          password: ${{ secrets.SERVER_PASSWORD }}
+          port: ${{ secrets.SERVER_PORT }}
+          script: |
+            "if screen -list | grep -q '${{ var.APP_NAME }}'; then screen -S ${{ var.APP_NAME }} -X quit && echo 'Screen session PetGuardian stopped.'; else echo 'No screen session named PetGuardian found.'; fi"
+            screen -dmS PetGuardian /usr/local/java/jdk1.8.0_202/bin/java -jar ${{ var.APP_NAME }}-0.0.1-SNAPSHOT.jar