优化管理后台

This commit is contained in:
2026-09-14 01:16:41 +08:00
parent 17b4ec85c3
commit cfa2511048
5 changed files with 272 additions and 7 deletions
+29
View File
@@ -50,6 +50,11 @@ jobs:
SSH_HOST: ${{ vars.ZT_CLOSET_PROD_SSH_HOST }}
SSH_USER: ${{ vars.ZT_CLOSET_PROD_SSH_USER }}
run: |
# runner 默认未安装 rsync,先装上(生产机一般自带,无需处理)
if ! command -v rsync >/dev/null 2>&1; then
sudo apt-get update -y && sudo apt-get install -y rsync
fi
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "$SSH_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
@@ -97,3 +102,27 @@ jobs:
- name: 部署结果
if: always()
run: echo "前端部署流程结束(目标 ${{ env.DEPLOY_DIR }})"
- name: 通知钉钉
if: always()
env:
DINGTALK_TOKEN: ${{ secrets.ZT_CLOSET_DINGTALK_TOKEN }}
JOB_RESULT: ${{ jobs.build-and-deploy.result }}
run: |
if [ "$JOB_RESULT" = "success" ]; then
STATUS="✅ 前端部署成功"
COLOR="info"
else
STATUS="❌ 前端部署失败"
COLOR="warning"
fi
curl -s -X POST "https://oapi.dingtalk.com/robot/send?access_token=${DINGTALK_TOKEN}" \
-H 'Content-Type: application/json' \
-d "{
\"msgtype\": \"markdown\",
\"markdown\": {
\"title\": \"前端部署通知\",
\"text\": \"## 前端部署通知\n\n**结果**:<font color=\\\"${COLOR}\\\">${STATUS}</font>\n\n**触发人**:${{ gitea.actor }}\n**分支/标签**:${{ gitea.ref_name }}\n**提交**:[${{ gitea.sha }}](${{ gitea.server_url }}/${{ gitea.repository }}/commit/${{ gitea.sha }})\n**流水线**:[${{ gitea.run_id }}](${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }})\n"
}
}"
echo "钉钉通知已发送:${STATUS}"