Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Deploy site to Pages

# Builds the Docusaurus site and deploys it to GitHub Pages.
#
# The Docs section is synced from rossoctl/rossoctl:docs/ at build time
# (npm run sync-docs). Triggers:
# The Docs section is synced from rossoctl/rossoctl:docs/, and /cortex/install.sh
# from rossoctl/cortex:scripts/install.sh, at build time (npm run sync-docs). Triggers:
# - push to main (site source changed)
# - repository_dispatch (docs changed upstream; sent by
# rossoctl/rossoctl .github/workflows/docs-dispatch.yaml)
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Sync docs from rossoctl/rossoctl:docs
- name: Sync docs from rossoctl/rossoctl and installer from rossoctl/cortex
run: npm run sync-docs

- name: Build
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
# committed here, regenerated on every build:
# docs/ <- rossoctl/rossoctl:docs/ (Docs section)
# contributing/index.md <- rossoctl/rossoctl:CONTRIBUTING.md (Contributing page)
# cortex/ <- rossoctl/cortex:scripts/install.sh (served at /cortex/install.sh)
/docs
/contributing/index.md
/cortex

# --- Misc / editor ---
.DS_Store
Expand Down
10 changes: 10 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ const config: Config = {
'https://github.com/rossoctl/ecosystem-guide/tree/main/content/',
},
],
// Copies cortex/ (synced by scripts/sync-docs.sh) to build/cortex/, so
// /cortex/install.sh is served as a real file. `static/` can't be used:
// it's committed, and this file must not be.
() => ({
name: 'cortex-installer',
postBuild: async ({outDir}) =>
fs.cpSync(path.join(__dirname, 'cortex'), path.join(outDir, 'cortex'), {
recursive: true,
}),
}),
],

// Enables Mermaid diagram rendering (paired with markdown.mermaid: true).
Expand Down
4 changes: 2 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Netlify is used for PR deploy previews only. Production deploys go to GitHub
# Pages via .github/workflows/deploy.yaml. The build syncs docs from
# rossoctl/rossoctl (a no-op while docs/ is absent / docs are hidden), then
# builds the Docusaurus site. Remove this file if the repo leaves Netlify.
# rossoctl/rossoctl and the installer from rossoctl/cortex, then builds the
# Docusaurus site. Remove this file if the repo leaves Netlify.
[build]
command = "npm run sync-docs && npm run build"
publish = "build"
Expand Down
22 changes: 20 additions & 2 deletions scripts/sync-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
# sync-docs.sh — populate this site from the SOURCE OF TRUTH in rossoctl/rossoctl:
# 1. docs/ -> the site's docs/ (rendered as the Docs section)
# 2. CONTRIBUTING.md -> the site's contributing/index.md (Contributing page)
# and from rossoctl/cortex:
# 3. scripts/install.sh -> the site's cortex/install.sh (served at /cortex/install.sh)
#
# Both destinations are git-ignored here and regenerated on every build (CI runs
# All destinations are git-ignored here and regenerated on every build (CI runs
# this before `npm run build`; see .github/workflows/deploy.yaml). The canonical
# content lives in rossoctl/rossoctl — edit it there, not here.
# content lives in those upstream repos — edit it there, not here.
#
# Usage:
# ./scripts/sync-docs.sh [git-ref] # clone from GitHub (default: main)
# SRC_REPO=/path/to/local/rossoctl ./scripts/sync-docs.sh # use an existing local clone
# CORTEX_SRC_REPO=/path/to/local/cortex ./scripts/sync-docs.sh # likewise for cortex

set -euo pipefail

REF="${1:-main}"
REPO_URL="https://github.com/rossoctl/rossoctl.git" # source of truth
CORTEX_REPO_URL="${CORTEX_REPO_URL:-https://github.com/rossoctl/cortex.git}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SITE_DIR="$(dirname "$SCRIPT_DIR")"
SUBDIR="docs"
Expand Down Expand Up @@ -102,3 +106,17 @@ if [[ -f "$CONTRIB_SRC" ]]; then
else
echo "!! CONTRIBUTING.md not found at $CONTRIB_SRC (skipped Contributing page)." >&2
fi

# --- 3. Cortex installer: copy scripts/install.sh -> cortex/install.sh -------
# Fatal if missing: a published URL without the file would serve HTML to `sh`.
if [[ -n "${CORTEX_SRC_REPO:-}" ]]; then
CORTEX_SRC="$CORTEX_SRC_REPO"
else
CORTEX_SRC="$(mktemp -d)"
trap 'rm -rf ${TMP:+"$TMP"} "$CORTEX_SRC"' EXIT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion — this trap ... EXIT replaces the earlier one rather than appending.

In the common CI path both clones happen, so the earlier trap 'rm -rf "$TMP"' EXIT is discarded and this becomes the only handler. The ${TMP:+...} guard correctly compensates, so the current code is fine — but that correctness now depends on this trap remembering to re-list every earlier temp dir. A third synced repo would silently reintroduce the leak.

Registering one cleanup function would make that structural rather than something to remember:

CLEANUP_DIRS=()
cleanup() { [[ ${#CLEANUP_DIRS[@]} -gt 0 ]] && rm -rf "${CLEANUP_DIRS[@]}"; }
trap cleanup EXIT
# then: CLEANUP_DIRS+=("$TMP") / CLEANUP_DIRS+=("$CORTEX_SRC")

Low real impact — the leak is a temp dir in a runner that gets destroyed anyway. Raised for maintainability.

git clone --depth 1 --filter=blob:none --sparse "$CORTEX_REPO_URL" "$CORTEX_SRC"
git -C "$CORTEX_SRC" sparse-checkout set scripts
fi
mkdir -p "$SITE_DIR/cortex"
rsync -a "$CORTEX_SRC/scripts/install.sh" "$SITE_DIR/cortex/install.sh"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit — rsync -a on a single file gains nothing over cp -p here: no --delete, no exclusions, no directory recursion. rsync also isn't present in every minimal container image, though ubuntu-latest has it.

The existing rsync further up genuinely needs --delete/--exclude; this one doesn't.

echo "==> cortex/install.sh copied from ${CORTEX_SRC_REPO:-$CORTEX_REPO_URL}@$(git -C "$CORTEX_SRC" rev-parse --short HEAD)."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion — rev-parse fails when CORTEX_SRC_REPO isn't a git repo.

This runs git rev-parse --short HEAD unconditionally. Under set -euo pipefail, if a contributor points CORTEX_SRC_REPO at a plain directory (an extracted tarball, a vendored copy), this exits 128 and fails the whole sync after the file was already copied successfully. I confirmed the exit code locally.

The remote path is always a real clone, so this only affects local users — but it fails the step for what is just a log line. Suggest tolerating it:

CORTEX_REV="$(git -C "$CORTEX_SRC" rev-parse --short HEAD 2>/dev/null || echo 'unknown')"
echo "==> cortex/install.sh copied from ${CORTEX_SRC_REPO:-$CORTEX_REPO_URL}@${CORTEX_REV}."