feat(ci): 试点规范 2(test → LAN → 手动 ubuntu2)
All checks were successful
CI-CD-2 / test (push) Successful in 2s
CI-CD-2 / deploy-lan (push) Successful in 3s
CI-CD-2 / deploy-cloud (push) Has been skipped

This commit is contained in:
2026-11-10 14:46:47 +08:00
parent 6d590673ae
commit adb1328b75
8 changed files with 271 additions and 0 deletions

26
ci/test.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# 静态站门禁:关键文件存在 + HTML 引用的本地资源都存在
set -euo pipefail
cd "$(dirname "$0")/.."
for file in index.html robots.txt sitemap.xml llms.txt assets/css/style.css assets/js/main.js; do
[ -f "$file" ] || { echo "缺少 $file"; exit 1; }
done
grep -q 'assets/css/style.css?v=' index.html || { echo "index.html 缺少 CSS 版本参数"; exit 1; }
grep -q 'assets/js/main.js?v=' index.html || { echo "index.html 缺少 JS 版本参数"; exit 1; }
python3 - <<'PY'
import os
import re
import sys
html = open("index.html", encoding="utf-8").read()
refs = set(re.findall(r'(?:src|href)="(assets/[^"]+)"', html))
missing = sorted(ref for ref in refs if not os.path.exists(ref.split("?")[0]))
if missing:
print("index.html 引用了不存在的资源:")
print("\n".join(missing))
sys.exit(1)
print(f"资源引用检查通过({len(refs)} 个)")
PY