From 2aa0bf23ab16f3a09098b6c9b6a0ce332a87bb88 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Tue, 21 Apr 2026 16:01:32 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=20=E5=84=AA=E5=8C=96=20CI/CD=20=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=B5=81=E7=A8=8B=E8=88=87=E6=9B=B4=E6=96=B0=20MQTT?= =?UTF-8?q?=20=E5=BF=83=E8=B7=B3=E8=A6=8F=E7=AF=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修復 .gitea/workflows/deploy-demo.yaml:改用 bash 函式處理 tar 同步,容許 exit code 1 (檔案變動警告) 並攔截致命錯誤。 2. 更新 .agents/skills/mqtt-communication-specs/SKILL.md:簡化心跳上報 (Heartbeat) 規範,僅保留 firmware_version 與 temperature 欄位。 --- .agents/skills/mqtt-communication-specs/SKILL.md | 14 +++++++------- .gitea/workflows/deploy-demo.yaml | 12 +++++++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.agents/skills/mqtt-communication-specs/SKILL.md b/.agents/skills/mqtt-communication-specs/SKILL.md index 7e75a73..ad4f076 100644 --- a/.agents/skills/mqtt-communication-specs/SKILL.md +++ b/.agents/skills/mqtt-communication-specs/SKILL.md @@ -111,19 +111,19 @@ Mqtt3Client client = MqttClient.builder() 所有 Payload 統一採用 **JSON** 格式,字母一律為 **snake_case**。 -### 3.1 心跳上報 (Heartbeat) - `machine/{id}/heartbeat` -比照原 B010 邏輯,但去除不必要的 HTTP Header 開銷。 +### 3.1 心跳上報 (Heartbeat) - `machine/{serial_no}/heartbeat` +這是機台最主要的狀態上報包,整合了關鍵的機台資訊。 ```json { - "current_page": 1, - "firmware_version": "1.0.5", - "temperature": 25.5, - "door_status": 0, - "timestamp": "2026-04-14T09:00:00+08:00" + "firmware_version": "2.1.6", + "temperature": 20 } ``` +> [!NOTE] +> 為了降低傳輸開銷,目前僅要求上報 **韌體版本** 與 **溫度**。其餘狀態如連線/斷線已透過 LWT 與 $SYS 事件處理。 + ### 3.2 異常上報 (Error/Event) - `machine/{id}/error` 比照原 B013 邏輯。 diff --git a/.gitea/workflows/deploy-demo.yaml b/.gitea/workflows/deploy-demo.yaml index 6b8173b..f2bea5e 100644 --- a/.gitea/workflows/deploy-demo.yaml +++ b/.gitea/workflows/deploy-demo.yaml @@ -40,10 +40,16 @@ jobs: WWWGROUP=1000 WWWUSER=1000 docker compose -f compose.yaml up -d --build --wait - name: Step 2 - Deploy Code + shell: bash run: | - tar --ignore-failed-read --exclude='.git' --exclude='node_modules' --exclude='vendor' --exclude='storage' --exclude='bootstrap/cache' -cf - . | docker exec -i star-cloud-laravel tar -xf - -C /var/www/html/ - tar --ignore-failed-read --exclude='.git' --exclude='node_modules' --exclude='vendor' --exclude='storage' --exclude='bootstrap/cache' -cf - . | docker exec -i star-cloud-queue tar -xf - -C /var/www/html/ - tar --ignore-failed-read --exclude='.git' --exclude='node_modules' --exclude='vendor' --exclude='storage' --exclude='bootstrap/cache' -cf - . | docker exec -i star-cloud-mqtt-worker tar -xf - -C /var/www/html/ + deploy_to() { + tar --exclude='.git' --exclude='node_modules' --exclude='vendor' --exclude='storage' --exclude='bootstrap/cache' -cf - . 2>/dev/null | docker exec -i "$1" tar -xf - -C /var/www/html/ + # tar exit 1 = "file changed as we read it" (non-fatal), exit 2+ = fatal + [ "${PIPESTATUS[0]}" -le 1 ] + } + deploy_to star-cloud-laravel + deploy_to star-cloud-queue + deploy_to star-cloud-mqtt-worker docker exec star-cloud-laravel sh -c " chown -R 1000:1000 /var/www/html && mkdir -p /.npm && chown -R 1000:1000 /.npm &&