Feature/yksinkertaistetaan raportointi logiikkaa #22
@@ -33,6 +33,41 @@ else
|
|||||||
fi
|
fi
|
||||||
mkdir -p "$TARGET"
|
mkdir -p "$TARGET"
|
||||||
cp -a "$REPORT_DIR/." "$TARGET/"
|
cp -a "$REPORT_DIR/." "$TARGET/"
|
||||||
|
if [ ! -f "$TARGET/index.html" ]; then
|
||||||
|
items=()
|
||||||
|
while IFS= read -r -d '' f; do
|
||||||
|
items+=("$(basename "$f")")
|
||||||
|
done < <(find "$TARGET" -maxdepth 1 -type f ! -name index.html -print0 2>/dev/null || true)
|
||||||
|
while IFS= read -r -d '' d; do
|
||||||
|
name=$(basename "$d")
|
||||||
|
[ -f "$d/index.html" ] && items+=("$name")
|
||||||
|
done < <(find "$TARGET" -maxdepth 1 -type d ! -name . -print0 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ ${#items[@]} -gt 1 ]; then
|
||||||
|
{
|
||||||
|
echo '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">'
|
||||||
|
echo "<title>Test report ${SHA8}</title>"
|
||||||
|
echo '<style>body{font-family:sans-serif;margin:2em;max-width:960px}'
|
||||||
|
echo 'h1{color:#1e293b}ul{list-style:none;padding:0}'
|
||||||
|
echo 'li{margin:.5em 0;padding:.5em;background:#f8fafc;border-radius:6px}'
|
||||||
|
echo 'a{color:#2563eb;text-decoration:none}a:hover{text-decoration:underline}'
|
||||||
|
echo '</style></head><body>'
|
||||||
|
echo "<h1>Test report <code>${SHA8}</code></h1><ul>"
|
||||||
|
for item in "${items[@]}"; do
|
||||||
|
label="${item%.*}"
|
||||||
|
label="${label//-/ }"
|
||||||
|
label="${label//_/ }"
|
||||||
|
if [ -f "$TARGET/$item" ]; then
|
||||||
|
echo "<li><a href=\"$item\">${label^}</a></li>"
|
||||||
|
else
|
||||||
|
echo "<li><a href=\"$item/index.html\">${label^}</a></li>"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo '</ul></body></html>'
|
||||||
|
} > "$TARGET/index.html"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
cat > "$TARGET/.meta" <<EOF
|
cat > "$TARGET/.meta" <<EOF
|
||||||
{"branch":"${GITHUB_REF_NAME:-}","sha":"${GITHUB_SHA}","published_at":"$(date -u +%Y-%m-%dT%H:%M:%SZ)"}
|
{"branch":"${GITHUB_REF_NAME:-}","sha":"${GITHUB_SHA}","published_at":"$(date -u +%Y-%m-%dT%H:%M:%SZ)"}
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user