name: Sync docs to superkit
on:
push:
branches: [main]
paths: ['docs/**']
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout superdb-mcp
uses: actions/checkout@v4
- name: Install SuperDB
uses: chrismo/asdf-superdb@main
- name: Load deploy key
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SUPERKIT_DEPLOY_KEY }}
- name: Clone superkit
run: git clone git@github.com:chrismo/superkit.git superkit
- name: Sync docs
run: |
set -euo pipefail
SUPERKIT_DIR="superkit"
DOCS_DIR="docs"
# Extract a YAML frontmatter field value using super
fm_field() {
super -i line -f line -c "where grep(\"^$2:\", this) | values regexp_replace(this, \"^$2: *\", \"\")" "$1"
}
# Extract body (everything after second ---) using super
fm_body() {
local end_line
end_line=$(super -i line -f line -c 'count {line: this, n} | where line == "---" | tail 1 | values n' "$1")
super -i line -f line -c "count {line: this, n} | where n > $end_line | values line" "$1"
}
# Extract first # heading using super
fm_heading() {
super -i line -f line -c 'where grep("^# ", this) | head 1 | values regexp_replace(this, "^# ", "")' "$1"
}
transform_frontmatter() {
local src="$1" dst="$2" title="$3" nav_order="$4" parent="${5:-}"
local description superdb_version last_updated
description=$(fm_field "$src" description)
superdb_version=$(fm_field "$src" superdb_version)
last_updated=$(fm_field "$src" last_updated)
# Write Jekyll frontmatter
{
echo "---"
echo "title: \"$title\""
[ -n "$description" ] && echo "description: $description"
echo "layout: default"
echo "nav_order: $nav_order"
[ -n "$parent" ] && echo "parent: Tutorials"
[ -n "$superdb_version" ] && echo "superdb_version: $superdb_version"
[ -n "$last_updated" ] && echo "last_updated: $last_updated"
echo "---"
} > "$dst"
# Append body
fm_body "$src" >> "$dst"
}
# Sync guide docs
mkdir -p "$SUPERKIT_DIR/_build/tutorials"
transform_frontmatter "$DOCS_DIR/superdb-expert.md" "$SUPERKIT_DIR/_build/expert-guide.md" "Expert Guide" 2
transform_frontmatter "$DOCS_DIR/zq-to-super-upgrades.md" "$SUPERKIT_DIR/_build/upgrade-guide.md" "Upgrade Guide" 3
# Sync tutorials
nav=1
for f in "$DOCS_DIR"/tutorials/*.md; do
name=$(basename "$f" .md)
heading=$(fm_heading "$f")
transform_frontmatter "$f" "$SUPERKIT_DIR/_build/tutorials/${name}.md" "$heading" "$nav" "tutorials"
nav=$((nav + 1))
done
# Commit and push
cd "$SUPERKIT_DIR"
git config user.name "superdb-mcp-sync"
git config user.email "superdb-mcp-sync@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "No changes to sync"
else
git commit -m "Sync docs from superdb-mcp"
git push
fi