diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index faf53368..981ef670 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: - name: "Check out repository code" uses: "actions/checkout@v6" - name: Check for file changes - uses: dorny/paths-filter@v3 + uses: dorny/paths-filter@v4 id: changes with: token: ${{ github.token }} diff --git a/docs/sidebars/sidebar-utils.ts b/docs/sidebars/sidebar-utils.ts index 0860904c..e13f3a10 100644 --- a/docs/sidebars/sidebar-utils.ts +++ b/docs/sidebars/sidebar-utils.ts @@ -1,3 +1,23 @@ +import { existsSync } from 'fs'; +import { join } from 'path'; + +/** + * Detects the base directory containing the docs content (python-sdk/, infrahubctl/, etc.). + * + * The sidebar files live in different locations depending on which repo they are in: + * - infrahub-sdk-python: docs/sidebars/ → content is at docs/docs/ + * - infrahub-docs: docs/ → content is at docs/docs-python-sdk/ + * + * We detect the active layout by checking whether the SDK-repo content path exists. + */ +export function getDocsBaseDir(): string { + const sdkRepoDocsDir = join(__dirname, '..', 'docs'); + if (existsSync(join(sdkRepoDocsDir, 'python-sdk'))) { + return sdkRepoDocsDir; + } + return join(__dirname, 'docs-python-sdk'); +} + export function getCommandItems(files: string[], indexFile: string = 'infrahubctl.mdx'): string[] { return files .filter(file => file.endsWith('.mdx') && file !== indexFile) diff --git a/docs/sidebars/sidebars-infrahubctl.ts b/docs/sidebars/sidebars-infrahubctl.ts index bd92511d..f8efded5 100644 --- a/docs/sidebars/sidebars-infrahubctl.ts +++ b/docs/sidebars/sidebars-infrahubctl.ts @@ -1,9 +1,9 @@ import type {SidebarsConfig} from '@docusaurus/plugin-content-docs'; import {readdirSync} from 'fs'; import {join} from 'path'; -import {getCommandItems} from './sidebar-utils'; +import {getCommandItems, getDocsBaseDir} from './sidebar-utils'; -const docsDir = join(__dirname, '..', 'docs', 'infrahubctl'); +const docsDir = join(getDocsBaseDir(), 'infrahubctl'); const commandItems = getCommandItems(readdirSync(docsDir)); const sidebars: SidebarsConfig = { diff --git a/docs/sidebars/sidebars-python-sdk.ts b/docs/sidebars/sidebars-python-sdk.ts index 3adbac3e..9f32420b 100644 --- a/docs/sidebars/sidebars-python-sdk.ts +++ b/docs/sidebars/sidebars-python-sdk.ts @@ -1,9 +1,9 @@ import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'; import { readdirSync } from 'fs'; import { join } from 'path'; -import { getItemsWithOrder } from './sidebar-utils'; +import { getDocsBaseDir, getItemsWithOrder } from './sidebar-utils'; -const pythonSdkDocsDir = join(__dirname, '..', 'docs', 'python-sdk'); +const pythonSdkDocsDir = join(getDocsBaseDir(), 'python-sdk'); const guidesItems = getItemsWithOrder( readdirSync(join(pythonSdkDocsDir, 'guides')),