Rework knowledgebase sync; add kb-publish for GitLab Pages

- Rename sync-knowledgebases to kb-sync (drop the aliased indirection)
- Generalize source discovery: scan each ~/work project for either
  docs/knowledgebase or documentation/knowledgebase
- Add kb-publish: rsync collected docs into the site repo, build the
  MkDocs site, and commit/push to publish to GitLab Pages
This commit is contained in:
Eric Wagoner
2026-08-27 12:57:34 -04:00
parent 88a71a026f
commit 8d656d8e7d
+29 -8
View File
@@ -59,22 +59,43 @@ alias yalp:start='core && make local_db_start && make local_run_api'
alias yalp:perf='core && boring list 2>/dev/null | tail -n +2 | awk "{print \$2}" | while read -r t; do boring close "$t" 2>/dev/null; done; lsof -ti :9258 | xargs kill 2>/dev/null; make local_container_db && make local_perf_db_start && make local_perf_run_api &>/dev/null & echo "YALP Core perf API starting on :9258 (pid $!)"'
alias yalp:perf:stop='lsof -ti :9258 | xargs kill 2>/dev/null && echo "YALP Core perf API stopped" || echo "No process on :9258"'
# Sync knowledgebase docs from all ~/work projects into ~/work/knowledgebases
sync-knowledgebases() {
# Collect knowledgebase docs from all ~/work projects into ~/work/knowledgebases.
# Shareable with teammates — no site-specific dependencies.
kb-sync() {
local src_base="$HOME/work"
local dest_base="$HOME/work/knowledgebases"
mkdir -p "$dest_base"
for dir in "$src_base"/*/docs/knowledgebase; do
[[ -d "$dir" ]] || continue
local project="${dir%/docs/knowledgebase}"
for project_dir in "$src_base"/*/; do
local project="${project_dir%/}"
project="${project##*/}"
local kb_dir=""
for candidate in "$project_dir"docs/knowledgebase "$project_dir"documentation/knowledgebase; do
[[ -d "$candidate" ]] && kb_dir="$candidate" && break
done
[[ -z "$kb_dir" ]] && continue
echo "Syncing $project..."
rm -rf "$dest_base/$project"
cp -R "$dir" "$dest_base/$project"
cp -R "$kb_dir" "$dest_base/$project"
done
echo "Done."
echo "Done. Knowledgebases collected in $dest_base"
}
# Build and publish the browsable knowledgebase site to GitLab Pages.
# Runs kb-sync first, then updates the site repo.
kb-publish() {
local dest_base="$HOME/work/knowledgebases"
local site_repo="$HOME/work/yalp-knowledgebases"
kb-sync
if [[ ! -d "$site_repo" ]]; then
echo "Site repo not found at $site_repo — clone ewagoner/yalp-knowledgebases first."
return 1
fi
echo "Updating site repo..."
rsync -av --delete "$dest_base/" "$site_repo/knowledgebases/"
python3 "$site_repo/scripts/build_site.py"
(cd "$site_repo" && git add -A && git commit -m "sync: $(date +%Y-%m-%d)" && git push)
echo "Site published."
}
alias kb-sync='sync-knowledgebases'
# Natera repos use master as primary; rewrite "git switch main" to "git switch master"
git() {