address code review: portable find, jq for JSON construction

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/4d7b9c05-531f-4e93-a770-f9324c663c38
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 10:21:43 +00:00
parent a10e020d26
commit 0f35d8bf90
2 changed files with 12 additions and 3 deletions

View File

@ -546,8 +546,16 @@ jobs:
# 写入部署状态文件 # 写入部署状态文件
TIMESTAMP=\$(date -u '+%Y-%m-%dT%H:%M:%SZ') TIMESTAMP=\$(date -u '+%Y-%m-%dT%H:%M:%SZ')
printf '{\"last_deploy\":\"%s\",\"commit\":\"${{ github.sha }}\",\"modules_passed\":%d,\"modules_failed\":%d}' \ if command -v jq &>/dev/null; then
\"\$TIMESTAMP\" \"\$PASSED\" \"\$FAILED\" > \"\$DP/data/deploy-status.json\" 2>/dev/null || true jq -n --arg ts \"\$TIMESTAMP\" --arg commit \"${{ github.sha }}\" \
--argjson passed \"\$PASSED\" --argjson failed \"\$FAILED\" \
'{last_deploy: \$ts, commit: \$commit, modules_passed: \$passed, modules_failed: \$failed}' \
> \"\$DP/data/deploy-status.json\" 2>/dev/null || true
else
printf '{\"last_deploy\":\"%s\",\"commit\":\"%s\",\"modules_passed\":%d,\"modules_failed\":%d}' \
\"\$TIMESTAMP\" \"${{ github.sha }}\" \"\$PASSED\" \"\$FAILED\" \
> \"\$DP/data/deploy-status.json\" 2>/dev/null || true
fi
" "
echo "✅ 冒烟测试完成" echo "✅ 冒烟测试完成"

View File

@ -151,7 +151,8 @@ for dir in "$DEPLOY_PATH" /var/www/hololake-frontend /var/www/hololake; do
echo "📂 $dir 最后修改时间:" echo "📂 $dir 最后修改时间:"
stat -c '%y' "$dir" 2>/dev/null || stat -f '%Sm' "$dir" 2>/dev/null || echo "⚠️ 无法获取" stat -c '%y' "$dir" 2>/dev/null || stat -f '%Sm' "$dir" 2>/dev/null || echo "⚠️ 无法获取"
echo "最新文件:" echo "最新文件:"
find "$dir" -type f -printf '%T@ %p\n' 2>/dev/null | sort -rn | head -5 find "$dir" -type f -exec stat -c '%Y %n' {} \; 2>/dev/null | sort -rn | head -5 || \
ls -lt "$dir" 2>/dev/null | head -6
fi fi
done done