diff --git a/.github/workflows/multirepo-connector-framework.yml b/.github/workflows/multirepo-connector-framework.yml index f9f2f86..bb4d18d 100644 --- a/.github/workflows/multirepo-connector-framework.yml +++ b/.github/workflows/multirepo-connector-framework.yml @@ -45,6 +45,58 @@ jobs: mkdir -p docs-repo/ground-control/robot-integration/connector-framework cp -r connector-repo/docs/mintlify/_build/* docs-repo/ground-control/robot-integration/connector-framework/ + - name: Merge navigation into docs.json + run: | + cd docs-repo + + NAV_FILE="ground-control/robot-integration/connector-framework/navigation.json" + DOCS_JSON="docs.json" + + if [ -f "$NAV_FILE" ]; then + echo "Merging connector framework navigation into docs.json..." + + # Validate navigation.json is valid JSON + if ! jq empty "$NAV_FILE" 2>/dev/null; then + echo "Error: navigation.json is not valid JSON" + exit 1 + fi + + # Read the navigation object + NAV_CONTENT=$(cat "$NAV_FILE") + + # Replace any existing connector framework entry with the new navigation. + # This handles both: + # - Simple string: "ground-control/robot-integration/connector-framework/index" + # - Existing group object: {"group": "Connector Framework", ...} + jq --argjson nav "$NAV_CONTENT" ' + (.navigation.products[] | + select(.product == "Ground Control") | + .tabs[] | + select(.tab == "Connecting Devices") | + .pages) |= map( + if (. == "ground-control/robot-integration/connector-framework/index") or + (type == "object" and .group == "Connector Framework") + then $nav + else . + end + ) + ' "$DOCS_JSON" > "${DOCS_JSON}.tmp" + + # Validate the resulting JSON is valid + if ! jq empty "${DOCS_JSON}.tmp" 2>/dev/null; then + echo "Error: Merge produced invalid JSON" + exit 1 + fi + + mv "${DOCS_JSON}.tmp" "$DOCS_JSON" + echo "Navigation merged successfully" + + # Clean up navigation.json from the copied docs + rm -f "$NAV_FILE" + else + echo "Warning: navigation.json not found, skipping merge" + fi + - name: Commit and push run: | cd docs-repo