diff --git a/scripts/ci-report.sh b/scripts/ci-report.sh index 1e833ed..9cc1dd7 100644 --- a/scripts/ci-report.sh +++ b/scripts/ci-report.sh @@ -17,18 +17,16 @@ if [ ! -d "$REPORT_DIR" ]; then exit 1 fi -cd "$REPORT_DIR" - FILES=() while IFS= read -r -d '' f; do FILES+=("$(basename "$f")") -done < <(find . -maxdepth 1 -type f ! -name index.html -print0 2>/dev/null || true) +done < <(find "$REPORT_DIR" -maxdepth 1 -type f ! -name index.html -print0 2>/dev/null || true) SUBDIRS=() while IFS= read -r -d '' d; do - name="${d#./}" - [ -f "$name/index.html" ] && SUBDIRS+=("$name") -done < <(find . -maxdepth 1 -type d ! -name . -print0 2>/dev/null || true) + name="${d#$REPORT_DIR/}" + [ -f "$d/index.html" ] && SUBDIRS+=("$name") +done < <(find "$REPORT_DIR" -maxdepth 1 -type d ! -name . -print0 2>/dev/null || true) TOTAL=$(( ${#FILES[@]} + ${#SUBDIRS[@]} )) @@ -61,26 +59,26 @@ generate_index() { html+="
  • ${d^}
  • " done html+='' - printf '%s' "$html" > index.html + printf '%s' "$html" > "$REPORT_DIR/index.html" } -cd - > /dev/null - -# Stage reports for backward-compatible publish STAGED="reports/${SHA8}/${SUITE}" mkdir -p "$STAGED" -cp -a "$REPORT_DIR/." "$STAGED/" if [ "$TOTAL" -eq 1 ]; then + cp -a "$REPORT_DIR/." "$STAGED/" + bash .ci/scripts/publish-git-pages.sh "$SUITE" + if [ ${#FILES[@]} -eq 1 ]; then ENTRY="${FILES[0]}" else ENTRY="${SUBDIRS[0]}/index.html" fi - bash .ci/scripts/publish-git-pages.sh "$SUITE" URL="${GIT_PAGES_URL}/${GITHUB_REPOSITORY}/reports/${SHA8}/${SUITE}/${ENTRY}" bash .ci/scripts/report-status.sh success "$DESCRIPTION" "$CONTEXT" "" "$URL" else + generate_index + cp -a "$REPORT_DIR/." "$STAGED/" bash .ci/scripts/publish-git-pages.sh "$SUITE" bash .ci/scripts/report-status.sh success "$DESCRIPTION" "$CONTEXT" "$SUITE" fi