diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 12e3f9030383..077ba4875654 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -21,6 +21,7 @@ on: docusaurus_pr_number: required: false type: number + default: -1 docusaurus_pr_url: required: false type: string diff --git a/.github/workflows/_deploy.yml b/.github/workflows/_deploy.yml index a77eda0f46c3..4f022dc22909 100644 --- a/.github/workflows/_deploy.yml +++ b/.github/workflows/_deploy.yml @@ -21,6 +21,10 @@ on: description: AWS S3 prefix where to store the build. required: true type: string + cf_invalidate_path: + description: Path to invalidate on CloudFront after deployment. + required: true + type: string concurrency: deploy-${{ github.ref }} @@ -64,4 +68,4 @@ jobs: --paths ${PATH_TO_INVALIDATE} env: CF_DISTRIBUTION_ID: ${{ vars.CF_DISTRIBUTION_ID }} - PATH_TO_INVALIDATE: '/${{ inputs.s3_prefix }}*' + PATH_TO_INVALIDATE: ${{ inputs.cf_invalidate_path }} diff --git a/.github/workflows/_undeploy.yml b/.github/workflows/_undeploy.yml index a2c5f35e2cad..23872655faa5 100644 --- a/.github/workflows/_undeploy.yml +++ b/.github/workflows/_undeploy.yml @@ -10,6 +10,10 @@ on: description: AWS S3 prefix where the build is located. required: true type: string + cf_invalidate_path: + description: Path to invalidate on CloudFront after deployment. + required: true + type: string concurrency: deploy-${{ github.ref }} @@ -45,4 +49,4 @@ jobs: --paths ${PATH_TO_INVALIDATE} env: CF_DISTRIBUTION_ID: ${{ vars.CF_DISTRIBUTION_ID }} - PATH_TO_INVALIDATE: '/${{ inputs.s3_prefix }}*' + PATH_TO_INVALIDATE: ${{ inputs.cf_invalidate_path }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 363bca042dfb..6b54b3081fc4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,3 +27,4 @@ jobs: environment_name: production artifact_name: ${{ needs.build.outputs.artifact_name }} s3_prefix: 'docs' + cf_invalidate_path: '/*' diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7a9b84e15ea4..4c5d47dbbd2e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -41,6 +41,7 @@ jobs: environment_url: '${{ vars.PREVIEW_CLOUDFRONT_URL }}/pr-${{ github.event.number }}/' artifact_name: ${{ needs.build.outputs.artifact_name }} s3_prefix: 'pr-${{ github.event.number }}' + cf_invalidate_path: '/pr-${{ github.event.number }}*' undeploy: name: undeploy @@ -49,3 +50,4 @@ jobs: with: environment_name: preview s3_prefix: 'pr-${{ github.event.number }}' + cf_invalidate_path: '/pr-${{ github.event.number }}*' diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 826976780f97..f8b709647e47 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -83,10 +83,10 @@ const docsConfigBase = { } satisfies DocsPlugin.Options; // Remove the index.md[x] from categories -function removeDocIndexItems(items) { +function removeDocIndexItems(items: any) { const result = items - .filter((item) => item.type !== 'doc' || !item.id.endsWith('/index')) - .map((item) => { + .filter((item: any) => item.type !== 'doc' || !item.id.endsWith('/index')) + .map((item: any) => { if (item.type === 'category') { return { ...item, items: removeDocIndexItems(item.items) }; } @@ -96,6 +96,8 @@ function removeDocIndexItems(items) { return result; } +const PR_NUMBER = Number(process.env.DOCUSAURUS_PR_NUMBER ?? -1); + const config: Config = { title: 'Dolby OptiView Documentation', tagline: 'Discover the latest developer documentation and samples for OptiView products', @@ -453,7 +455,7 @@ const config: Config = { parseFrontMatter: async (params) => { const result = await params.defaultParseFrontMatter(params); const { frontMatter } = result; - const parsedDocPath = parseDocPath(params.filePath); + const parsedDocPath = parseDocPath(params.filePath)!; const { docPluginId } = parsedDocPath; let { docPath } = parsedDocPath; if (!frontMatter.slug && docPath.startsWith('external/')) { @@ -535,18 +537,19 @@ const config: Config = { // image: 'img/opengraph.png', // announcement bar for PR preview only - announcementBar: process.env.DOCUSAURUS_PR_NUMBER - ? { - id: 'pr_preview', - content: `This is a preview of the documentation website from pull request #${process.env.DOCUSAURUS_PR_NUMBER}.`, - backgroundColor: '#9cb9c9', - textColor: '#344a5e', - isCloseable: false, - } - : undefined, + announcementBar: + PR_NUMBER > 0 + ? { + id: 'pr_preview', + content: `This is a preview of the documentation website from pull request #${process.env.DOCUSAURUS_PR_NUMBER}.`, + backgroundColor: '#9cb9c9', + textColor: '#344a5e', + isCloseable: false, + } + : undefined, navbar: { - title: null, + title: undefined, logo: { alt: 'Dolby OptiView', src: 'img/dolby-optiview-white.svg',