Repository navigation
Feat: serve cortex installer at /cortex/install.sh #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
|
@@ -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 | ||
| 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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit — The existing |
||
| echo "==> cortex/install.sh copied from ${CORTEX_SRC_REPO:-$CORTEX_REPO_URL}@$(git -C "$CORTEX_SRC" rev-parse --short HEAD)." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion — This runs 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}." |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion — this
trap ... EXITreplaces the earlier one rather than appending.In the common CI path both clones happen, so the earlier
trap 'rm -rf "$TMP"' EXITis 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:
Low real impact — the leak is a temp dir in a runner that gets destroyed anyway. Raised for maintainability.