From 15e6ee59cbe8a3ad142f55a22664506bbae6da71 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 17 Dec 2025 12:11:12 -0300 Subject: [PATCH 01/18] Allow limited public assembler builds on docs-builder --- .github/workflows/preview-build.yml | 28 ++++++++++++++++++++++++++++ config/assembler.yml | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 837cec41c..39b5bd7df 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -6,6 +6,7 @@ on: - opened - synchronize - reopened + - labeled push: branches: - main @@ -516,6 +517,33 @@ jobs: environment_url: `https://docs-v3-preview.elastic.dev${process.env.LANDING_PAGE_PATH}`, log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, }) + + - name: Build assembled documentation + id: internal-assembler-build + if: > + github.repository == 'elastic/docs-builder' + && steps.deployment.outputs.result + && contains(github.event.pull_request.labels.*.name, 'assembler-preview') + env: + ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} + run: | + yq -i ".environments.preview.path_prefix = \"${ASSEMBLER_PREVIEW_PATH_PREFIX}\"" config/assembler.yml + dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview + + - name: Upload assembled docs to S3 + if: > + github.repository == 'elastic/docs-builder' + && steps.internal-assembler-build.outcome == 'success' + env: + AWS_RETRY_MODE: standard + AWS_MAX_ATTEMPTS: 6 + ASSEMBLER_PREVIEW_PATH_PREFIX: /${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} + run: | + aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks + aws cloudfront create-invalidation \ + --distribution-id EKT7LT5PM8RKS \ + --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" + comment: if: > startsWith(github.event_name, 'pull_request') diff --git a/config/assembler.yml b/config/assembler.yml index 40b2c7311..5c9106742 100644 --- a/config/assembler.yml +++ b/config/assembler.yml @@ -36,6 +36,14 @@ environments: path_prefix: docs feature_flags: SEARCH_OR_ASK_AI: true + preview: + uri: https://docs-v3-preview.elastic.dev + path_prefix: ${ASSEMBLER_PREVIEW_PATH_PREFIX} + content_source: current + google_tag_manager: + enabled: false + feature_flags: + SEARCH_OR_ASK_AI: true shared_configuration: stack: &stack From fc05e7eb59e3fd902579403cb8a5fe68bf8e6cdd Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 17 Dec 2025 12:35:59 -0300 Subject: [PATCH 02/18] Use path prefix for llms.txt when available --- src/Elastic.Markdown/Exporters/LlmMarkdownExporter.cs | 2 +- .../Building/AssemblerBuildService.cs | 3 ++- .../Building/AssemblerBuilder.cs | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Elastic.Markdown/Exporters/LlmMarkdownExporter.cs b/src/Elastic.Markdown/Exporters/LlmMarkdownExporter.cs index 2ac6eab21..09e78ddad 100644 --- a/src/Elastic.Markdown/Exporters/LlmMarkdownExporter.cs +++ b/src/Elastic.Markdown/Exporters/LlmMarkdownExporter.cs @@ -48,7 +48,7 @@ public class LlmMarkdownExporter : IMarkdownExporter public async ValueTask FinishExportAsync(IDirectoryInfo outputFolder, Cancel ctx) { - var outputDirectory = Path.Combine(outputFolder.FullName, "docs"); + var outputDirectory = outputFolder.FullName; var zipPath = Path.Combine(outputDirectory, "llm.zip"); // Create the llms.txt file with boilerplate content diff --git a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs index 5e72221a7..9ecac2585 100644 --- a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs +++ b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs @@ -140,7 +140,8 @@ Cancel ctx private static async Task EnhanceLlmsTxtFile(AssembleContext context, SiteNavigation navigation, LlmsNavigationEnhancer enhancer, Cancel ctx) { - var llmsTxtPath = Path.Combine(context.OutputDirectory.FullName, "docs", "llms.txt"); + var pathPrefix = context.Environment.PathPrefix ?? "docs"; + var llmsTxtPath = Path.Combine(context.OutputDirectory.FullName, pathPrefix, "llms.txt"); var readFs = context.ReadFileSystem; if (!readFs.File.Exists(llmsTxtPath)) diff --git a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs index a6410ffbf..49c2f197d 100644 --- a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs +++ b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs @@ -75,7 +75,11 @@ public async Task BuildAllAsync(PublishEnvironment environment, FrozenDictionary foreach (var exporter in markdownExporters) { _logger.LogInformation("Calling FinishExportAsync on {ExporterName}", exporter.GetType().Name); - _ = await exporter.FinishExportAsync(context.OutputDirectory, ctx); + var pathPrefix = context.Environment.PathPrefix; + var outputWithPrefix = string.IsNullOrEmpty(pathPrefix) + ? context.OutputDirectory + : context.ReadFileSystem.DirectoryInfo.New(Path.Combine(context.OutputDirectory.FullName, pathPrefix)); + _ = await exporter.FinishExportAsync(outputWithPrefix, ctx); } if (exportOptions.Contains(Exporter.Redirects)) From 3b228a034b68d25ca28ce9bc27f4de3fc13a524e Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 17 Dec 2025 12:46:52 -0300 Subject: [PATCH 03/18] Adjust link-index.snapshot generation with path prefixes --- .../Sourcing/RepositorySourcesFetcher.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/services/Elastic.Documentation.Assembler/Sourcing/RepositorySourcesFetcher.cs b/src/services/Elastic.Documentation.Assembler/Sourcing/RepositorySourcesFetcher.cs index 5f7fa220e..ad3056ce3 100644 --- a/src/services/Elastic.Documentation.Assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/services/Elastic.Documentation.Assembler/Sourcing/RepositorySourcesFetcher.cs @@ -117,11 +117,15 @@ await context.WriteFileSystem.File.WriteAllTextAsync( }; } - public async Task WriteLinkRegistrySnapshot(LinkRegistry linkRegistrySnapshot, Cancel ctx = default) => await context.WriteFileSystem.File.WriteAllTextAsync( - Path.Combine(context.OutputDirectory.FullName, "docs", CheckoutResult.LinkRegistrySnapshotFileName), + public async Task WriteLinkRegistrySnapshot(LinkRegistry linkRegistrySnapshot, Cancel ctx = default) + { + var pathPrefix = context.Environment.PathPrefix ?? "docs"; + await context.WriteFileSystem.File.WriteAllTextAsync( + Path.Combine(context.OutputDirectory.FullName, pathPrefix, CheckoutResult.LinkRegistrySnapshotFileName), LinkRegistry.Serialize(linkRegistrySnapshot), ctx ); + } } From 4ca18057f4d4ba55b51bf5275a8c27915b610816 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 17 Dec 2025 12:57:29 -0300 Subject: [PATCH 04/18] Adjust sitemap.xml generation to use path prefixes when available. --- .../Building/AssemblerBuildService.cs | 10 +++++++--- .../Building/SitemapBuilder.cs | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs index 9ecac2585..420ed3f82 100644 --- a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs +++ b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs @@ -120,7 +120,11 @@ Cancel ctx if (exporters.Contains(Exporter.Html)) { - var sitemapBuilder = new SitemapBuilder(navigation.NavigationItems, assembleContext.WriteFileSystem, assembleContext.OutputDirectory); + var pathPrefix = assembleContext.Environment.PathPrefix; + var outputWithPrefix = string.IsNullOrEmpty(pathPrefix) + ? assembleContext.OutputDirectory + : assembleContext.WriteFileSystem.DirectoryInfo.New(Path.Combine(assembleContext.OutputDirectory.FullName, pathPrefix)); + var sitemapBuilder = new SitemapBuilder(navigation.NavigationItems, assembleContext.WriteFileSystem, outputWithPrefix); sitemapBuilder.Generate(); } @@ -140,10 +144,10 @@ Cancel ctx private static async Task EnhanceLlmsTxtFile(AssembleContext context, SiteNavigation navigation, LlmsNavigationEnhancer enhancer, Cancel ctx) { + var readFs = context.ReadFileSystem; var pathPrefix = context.Environment.PathPrefix ?? "docs"; - var llmsTxtPath = Path.Combine(context.OutputDirectory.FullName, pathPrefix, "llms.txt"); + var llmsTxtPath = readFs.Path.Combine(context.OutputDirectory.FullName, pathPrefix, "llms.txt"); - var readFs = context.ReadFileSystem; if (!readFs.File.Exists(llmsTxtPath)) return; // No llms.txt file to enhance diff --git a/src/services/Elastic.Documentation.Assembler/Building/SitemapBuilder.cs b/src/services/Elastic.Documentation.Assembler/Building/SitemapBuilder.cs index 2059be9d9..d029032ad 100644 --- a/src/services/Elastic.Documentation.Assembler/Building/SitemapBuilder.cs +++ b/src/services/Elastic.Documentation.Assembler/Building/SitemapBuilder.cs @@ -54,7 +54,7 @@ public void Generate() doc.Add(root); - using var fileStream = fileSystem.File.Create(Path.Combine(outputFolder.ToString() ?? string.Empty, "docs", "sitemap.xml")); + using var fileStream = fileSystem.File.Create(Path.Combine(outputFolder.FullName, "sitemap.xml")); doc.Save(fileStream); } From ed133bf248686253963fb69fb0637638c4affc6d Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 17 Dec 2025 13:07:22 -0300 Subject: [PATCH 05/18] Remove extra slash --- .github/workflows/preview-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 39b5bd7df..916dce3a1 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -537,7 +537,7 @@ jobs: env: AWS_RETRY_MODE: standard AWS_MAX_ATTEMPTS: 6 - ASSEMBLER_PREVIEW_PATH_PREFIX: /${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} + ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} run: | aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks aws cloudfront create-invalidation \ From 71dbdaf261de3b098e91c58a9f8a661c6360e269 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 17 Dec 2025 13:43:02 -0300 Subject: [PATCH 06/18] Create assembler deployment process --- .github/workflows/preview-build.yml | 58 ++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 916dce3a1..a8fc093e2 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -518,12 +518,45 @@ jobs: log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, }) - - name: Build assembled documentation - id: internal-assembler-build + - name: Create Assembler Deployment if: > github.repository == 'elastic/docs-builder' && steps.deployment.outputs.result && contains(github.event.pull_request.labels.*.name, 'assembler-preview') + uses: actions/github-script@v8 + id: assembler-deployment + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + REF: ${{ github.event.pull_request.head.sha }} + with: + result-encoding: string + script: | + const { owner, repo } = context.repo; + const prNumber = process.env.PR_NUMBER; + const environment = 'assembler-preview'; + const task = `assembler-preview-${prNumber}`; + const deployment = await github.rest.repos.createDeployment({ + owner, + repo, + environment, + task, + ref: process.env.REF, + auto_merge: false, + transient_environment: true, + required_contexts: [], + }) + await github.rest.repos.createDeploymentStatus({ + deployment_id: deployment.data.id, + owner, + repo, + state: "in_progress", + log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, + }) + return deployment.data.id + + - name: Build assembled documentation + id: internal-assembler-build + if: steps.assembler-deployment.outputs.result env: ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} run: | @@ -531,9 +564,8 @@ jobs: dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview - name: Upload assembled docs to S3 - if: > - github.repository == 'elastic/docs-builder' - && steps.internal-assembler-build.outcome == 'success' + id: assembler-s3-upload + if: steps.internal-assembler-build.outcome == 'success' env: AWS_RETRY_MODE: standard AWS_MAX_ATTEMPTS: 6 @@ -543,6 +575,22 @@ jobs: aws cloudfront create-invalidation \ --distribution-id EKT7LT5PM8RKS \ --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" + + - name: Update Assembler Deployment Status + if: always() && steps.assembler-deployment.outputs.result + uses: actions/github-script@v8 + env: + ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} + with: + script: | + await github.rest.repos.createDeploymentStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + deployment_id: ${{ steps.assembler-deployment.outputs.result || 0 }}, + state: "${{ steps.assembler-s3-upload.outcome == 'success' && 'success' || 'failure' }}", + environment_url: `https://docs-v3-preview.elastic.dev/${process.env.ASSEMBLER_PREVIEW_PATH_PREFIX}`, + log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, + }) comment: if: > From ebf0abb3e2715d3c5f3b9db54a257e78edeacc7b Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 17 Dec 2025 14:02:07 -0300 Subject: [PATCH 07/18] Apply automated fix to 'Call to System.IO.Path.Combine' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- .../Sourcing/RepositorySourcesFetcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/Elastic.Documentation.Assembler/Sourcing/RepositorySourcesFetcher.cs b/src/services/Elastic.Documentation.Assembler/Sourcing/RepositorySourcesFetcher.cs index ad3056ce3..90bb4066b 100644 --- a/src/services/Elastic.Documentation.Assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/services/Elastic.Documentation.Assembler/Sourcing/RepositorySourcesFetcher.cs @@ -121,7 +121,7 @@ public async Task WriteLinkRegistrySnapshot(LinkRegistry linkRegistrySnapshot, C { var pathPrefix = context.Environment.PathPrefix ?? "docs"; await context.WriteFileSystem.File.WriteAllTextAsync( - Path.Combine(context.OutputDirectory.FullName, pathPrefix, CheckoutResult.LinkRegistrySnapshotFileName), + context.WriteFileSystem.Path.Combine(context.OutputDirectory.FullName, pathPrefix, CheckoutResult.LinkRegistrySnapshotFileName), LinkRegistry.Serialize(linkRegistrySnapshot), ctx ); From 31f208ec44dcafaf6a4dabdabc859a619723e702 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 17 Dec 2025 14:05:23 -0300 Subject: [PATCH 08/18] Apply remaining updates --- .../Building/AssemblerBuildService.cs | 2 +- .../Building/AssemblerBuilder.cs | 2 +- .../Elastic.Documentation.Assembler/Building/SitemapBuilder.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs index 420ed3f82..e9e3524ce 100644 --- a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs +++ b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuildService.cs @@ -123,7 +123,7 @@ Cancel ctx var pathPrefix = assembleContext.Environment.PathPrefix; var outputWithPrefix = string.IsNullOrEmpty(pathPrefix) ? assembleContext.OutputDirectory - : assembleContext.WriteFileSystem.DirectoryInfo.New(Path.Combine(assembleContext.OutputDirectory.FullName, pathPrefix)); + : assembleContext.WriteFileSystem.DirectoryInfo.New(assembleContext.WriteFileSystem.Path.Combine(assembleContext.OutputDirectory.FullName, pathPrefix)); var sitemapBuilder = new SitemapBuilder(navigation.NavigationItems, assembleContext.WriteFileSystem, outputWithPrefix); sitemapBuilder.Generate(); } diff --git a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs index 49c2f197d..de2f94d81 100644 --- a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs +++ b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs @@ -78,7 +78,7 @@ public async Task BuildAllAsync(PublishEnvironment environment, FrozenDictionary var pathPrefix = context.Environment.PathPrefix; var outputWithPrefix = string.IsNullOrEmpty(pathPrefix) ? context.OutputDirectory - : context.ReadFileSystem.DirectoryInfo.New(Path.Combine(context.OutputDirectory.FullName, pathPrefix)); + : context.ReadFileSystem.DirectoryInfo.New(Path.Join(context.OutputDirectory.FullName, pathPrefix)); _ = await exporter.FinishExportAsync(outputWithPrefix, ctx); } diff --git a/src/services/Elastic.Documentation.Assembler/Building/SitemapBuilder.cs b/src/services/Elastic.Documentation.Assembler/Building/SitemapBuilder.cs index d029032ad..a45a2ec51 100644 --- a/src/services/Elastic.Documentation.Assembler/Building/SitemapBuilder.cs +++ b/src/services/Elastic.Documentation.Assembler/Building/SitemapBuilder.cs @@ -54,7 +54,7 @@ public void Generate() doc.Add(root); - using var fileStream = fileSystem.File.Create(Path.Combine(outputFolder.FullName, "sitemap.xml")); + using var fileStream = fileSystem.File.Create(fileSystem.Path.Combine(outputFolder.FullName, "sitemap.xml")); doc.Save(fileStream); } From f46f6997660942dc40e6518a0d746aaa2a2bbae1 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Thu, 18 Dec 2025 13:05:23 -0300 Subject: [PATCH 09/18] Move the assembler preview to a separate workflow --- .github/workflows/assembler-preview.yml | 127 ++++++++++++++++++++++++ .github/workflows/preview-build.yml | 106 +++----------------- 2 files changed, 142 insertions(+), 91 deletions(-) create mode 100644 .github/workflows/assembler-preview.yml diff --git a/.github/workflows/assembler-preview.yml b/.github/workflows/assembler-preview.yml new file mode 100644 index 000000000..3cab1d97e --- /dev/null +++ b/.github/workflows/assembler-preview.yml @@ -0,0 +1,127 @@ +name: assembler-preview + +on: + workflow_dispatch: + inputs: + pr_number: + description: 'Pull Request number to build the assembler preview for' + required: true + type: string + +permissions: + contents: read + deployments: write + id-token: write + pull-requests: read + +concurrency: + group: assembler-preview-${{ inputs.pr_number }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + env: + PR_NUMBER: ${{ inputs.pr_number }} + ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/docs/${{ inputs.pr_number }} + steps: + - name: Get PR details + id: pr-details + uses: actions/github-script@v8 + with: + result-encoding: json + script: | + const { owner, repo } = context.repo; + const prNumber = parseInt(process.env.PR_NUMBER, 10); + + if (isNaN(prNumber) || prNumber <= 0) { + core.setFailed(`Invalid PR number: ${process.env.PR_NUMBER}`); + return; + } + + try { + const { data: pr } = await github.rest.pulls.get({ + owner, + repo, + pull_number: prNumber, + }); + + return { + sha: pr.head.sha, + ref: pr.head.ref, + base_ref: pr.base.ref, + }; + } catch (error) { + core.setFailed(`Failed to get PR #${prNumber}: ${error.message}`); + } + + - name: Checkout PR + uses: actions/checkout@v6 + with: + ref: ${{ fromJSON(steps.pr-details.outputs.result).sha }} + persist-credentials: false + + - name: Create Deployment + uses: actions/github-script@v8 + id: deployment + with: + result-encoding: string + script: | + const { owner, repo } = context.repo; + const prNumber = process.env.PR_NUMBER; + const environment = 'assembler-preview'; + const task = `assembler-preview-${prNumber}`; + const deployment = await github.rest.repos.createDeployment({ + owner, + repo, + environment, + task, + ref: '${{ fromJSON(steps.pr-details.outputs.result).sha }}', + auto_merge: false, + transient_environment: true, + required_contexts: [], + }) + await github.rest.repos.createDeploymentStatus({ + deployment_id: deployment.data.id, + owner, + repo, + state: "in_progress", + log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, + }) + return deployment.data.id + + - name: Bootstrap Action Workspace + uses: elastic/docs-builder/.github/actions/bootstrap@main + + - name: Build assembled documentation + id: assembler-build + run: | + yq -i ".environments.preview.path_prefix = \"${ASSEMBLER_PREVIEW_PATH_PREFIX}\"" config/assembler.yml + dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview + + - uses: elastic/docs-builder/.github/actions/aws-auth@main + + - name: Upload assembled docs to S3 + id: s3-upload + env: + AWS_RETRY_MODE: standard + AWS_MAX_ATTEMPTS: 6 + run: | + aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks + aws cloudfront create-invalidation \ + --distribution-id EKT7LT5PM8RKS \ + --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" + + - name: Update Deployment Status + if: always() && steps.deployment.outputs.result + uses: actions/github-script@v8 + with: + script: | + await github.rest.repos.createDeploymentStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + deployment_id: ${{ steps.deployment.outputs.result }}, + state: "${{ steps.s3-upload.outcome == 'success' && 'success' || 'failure' }}", + environment_url: `https://docs-v3-preview.elastic.dev/${process.env.ASSEMBLER_PREVIEW_PATH_PREFIX}`, + log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, + }) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index a8fc093e2..a6476c6a9 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -6,7 +6,6 @@ on: - opened - synchronize - reopened - - labeled push: branches: - main @@ -64,14 +63,14 @@ on: type: boolean default: false required: false - + permissions: contents: read deployments: write id-token: write pull-requests: write - + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }} cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }} @@ -80,7 +79,7 @@ jobs: match: if: github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks) runs-on: ubuntu-latest - permissions: + permissions: contents: none deployments: none pull-requests: none @@ -105,7 +104,7 @@ jobs: with: ref_name: ${{ steps.merge-group-base-branch.outputs.base_ref }} repository: ${{ github.repository }} - + - name: Match for PR events id: pr-check if: contains(fromJSON('["pull_request", "pull_request_target"]'), github.event_name) @@ -118,7 +117,7 @@ jobs: run: | echo "ref=${{ github.base_ref }}" echo "repo=${{ github.repository }}" - + - name: Match for push events id: push-check if: contains(fromJSON('["push"]'), github.event_name) @@ -131,7 +130,7 @@ jobs: run: | echo "ref=${{ github.ref_name }}" echo "repo=${{ github.repository }}" - + - name: Debug outputs run: | echo "content-source-match: ${{ format('{0}{1}{2}', steps.pr-check.outputs.content-source-match, steps.push-check.outputs.content-source-match, steps.merge-group-check.outputs.content-source-match) }}" @@ -142,7 +141,7 @@ jobs: check: runs-on: ubuntu-latest - needs: + needs: - match permissions: contents: read @@ -237,7 +236,7 @@ jobs: deployments: write id-token: write pull-requests: none - outputs: + outputs: deployment_result: ${{ steps.deployment.outputs.result }} path_prefix: ${{ steps.generate-path-prefix.outputs.result }} env: @@ -262,7 +261,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha || github.ref }} persist-credentials: false - + - name: Create Deployment if: > env.MATCH == 'true' @@ -409,7 +408,7 @@ jobs: ) ) uses: elastic/docs-builder/actions/validate-inbound-local@main - + - name: 'Validate inbound links' if: > env.MATCH == 'true' @@ -445,7 +444,7 @@ jobs: ) ) uses: elastic/docs-builder/actions/validate-path-prefixes-local@main - + - name: 'Validate local path prefixes against those claimed by global navigation.yml' if: > env.MATCH == 'true' @@ -517,81 +516,6 @@ jobs: environment_url: `https://docs-v3-preview.elastic.dev${process.env.LANDING_PAGE_PATH}`, log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, }) - - - name: Create Assembler Deployment - if: > - github.repository == 'elastic/docs-builder' - && steps.deployment.outputs.result - && contains(github.event.pull_request.labels.*.name, 'assembler-preview') - uses: actions/github-script@v8 - id: assembler-deployment - env: - PR_NUMBER: ${{ github.event.pull_request.number }} - REF: ${{ github.event.pull_request.head.sha }} - with: - result-encoding: string - script: | - const { owner, repo } = context.repo; - const prNumber = process.env.PR_NUMBER; - const environment = 'assembler-preview'; - const task = `assembler-preview-${prNumber}`; - const deployment = await github.rest.repos.createDeployment({ - owner, - repo, - environment, - task, - ref: process.env.REF, - auto_merge: false, - transient_environment: true, - required_contexts: [], - }) - await github.rest.repos.createDeploymentStatus({ - deployment_id: deployment.data.id, - owner, - repo, - state: "in_progress", - log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - }) - return deployment.data.id - - - name: Build assembled documentation - id: internal-assembler-build - if: steps.assembler-deployment.outputs.result - env: - ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} - run: | - yq -i ".environments.preview.path_prefix = \"${ASSEMBLER_PREVIEW_PATH_PREFIX}\"" config/assembler.yml - dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview - - - name: Upload assembled docs to S3 - id: assembler-s3-upload - if: steps.internal-assembler-build.outcome == 'success' - env: - AWS_RETRY_MODE: standard - AWS_MAX_ATTEMPTS: 6 - ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} - run: | - aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks - aws cloudfront create-invalidation \ - --distribution-id EKT7LT5PM8RKS \ - --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" - - - name: Update Assembler Deployment Status - if: always() && steps.assembler-deployment.outputs.result - uses: actions/github-script@v8 - env: - ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} - with: - script: | - await github.rest.repos.createDeploymentStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - deployment_id: ${{ steps.assembler-deployment.outputs.result || 0 }}, - state: "${{ steps.assembler-s3-upload.outcome == 'success' && 'success' || 'failure' }}", - environment_url: `https://docs-v3-preview.elastic.dev/${process.env.ASSEMBLER_PREVIEW_PATH_PREFIX}`, - log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - }) - comment: if: > startsWith(github.event_name, 'pull_request') @@ -602,7 +526,7 @@ jobs: needs: - check - build - permissions: + permissions: contents: none deployments: none id-token: none @@ -695,7 +619,7 @@ jobs: const owner = context.repo.owner; const repo = context.repo.repo; - + const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: prNum }); @@ -732,7 +656,7 @@ jobs: ### 🤔 Need help? - Check out the [cumulative docs guidelines](https://www.elastic.co/docs/contribute-docs/how-to/cumulative-docs/) - Reach out in the [#docs](https://elastic.slack.com/archives/C0JF80CJZ) Slack channel`; - + await github.rest.issues.createComment({ owner, repo, issue_number: prNum, @@ -760,7 +684,7 @@ jobs: persist-credentials: false - name: Run Vale Linter uses: elastic/vale-rules/lint@main - with: + with: files: ${{ needs.check.outputs.all_changed_files }} - name: Post Vale Results uses: elastic/vale-rules/report@main From 9fed4a862e538697a60b0a58af9054a6c713180c Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Thu, 18 Dec 2025 14:03:48 -0300 Subject: [PATCH 10/18] Revert "Move the assembler preview to a separate workflow" This reverts commit f46f6997660942dc40e6518a0d746aaa2a2bbae1. --- .github/workflows/assembler-preview.yml | 127 ------------------------ .github/workflows/preview-build.yml | 106 +++++++++++++++++--- 2 files changed, 91 insertions(+), 142 deletions(-) delete mode 100644 .github/workflows/assembler-preview.yml diff --git a/.github/workflows/assembler-preview.yml b/.github/workflows/assembler-preview.yml deleted file mode 100644 index 3cab1d97e..000000000 --- a/.github/workflows/assembler-preview.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: assembler-preview - -on: - workflow_dispatch: - inputs: - pr_number: - description: 'Pull Request number to build the assembler preview for' - required: true - type: string - -permissions: - contents: read - deployments: write - id-token: write - pull-requests: read - -concurrency: - group: assembler-preview-${{ inputs.pr_number }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - env: - PR_NUMBER: ${{ inputs.pr_number }} - ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/docs/${{ inputs.pr_number }} - steps: - - name: Get PR details - id: pr-details - uses: actions/github-script@v8 - with: - result-encoding: json - script: | - const { owner, repo } = context.repo; - const prNumber = parseInt(process.env.PR_NUMBER, 10); - - if (isNaN(prNumber) || prNumber <= 0) { - core.setFailed(`Invalid PR number: ${process.env.PR_NUMBER}`); - return; - } - - try { - const { data: pr } = await github.rest.pulls.get({ - owner, - repo, - pull_number: prNumber, - }); - - return { - sha: pr.head.sha, - ref: pr.head.ref, - base_ref: pr.base.ref, - }; - } catch (error) { - core.setFailed(`Failed to get PR #${prNumber}: ${error.message}`); - } - - - name: Checkout PR - uses: actions/checkout@v6 - with: - ref: ${{ fromJSON(steps.pr-details.outputs.result).sha }} - persist-credentials: false - - - name: Create Deployment - uses: actions/github-script@v8 - id: deployment - with: - result-encoding: string - script: | - const { owner, repo } = context.repo; - const prNumber = process.env.PR_NUMBER; - const environment = 'assembler-preview'; - const task = `assembler-preview-${prNumber}`; - const deployment = await github.rest.repos.createDeployment({ - owner, - repo, - environment, - task, - ref: '${{ fromJSON(steps.pr-details.outputs.result).sha }}', - auto_merge: false, - transient_environment: true, - required_contexts: [], - }) - await github.rest.repos.createDeploymentStatus({ - deployment_id: deployment.data.id, - owner, - repo, - state: "in_progress", - log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - }) - return deployment.data.id - - - name: Bootstrap Action Workspace - uses: elastic/docs-builder/.github/actions/bootstrap@main - - - name: Build assembled documentation - id: assembler-build - run: | - yq -i ".environments.preview.path_prefix = \"${ASSEMBLER_PREVIEW_PATH_PREFIX}\"" config/assembler.yml - dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview - - - uses: elastic/docs-builder/.github/actions/aws-auth@main - - - name: Upload assembled docs to S3 - id: s3-upload - env: - AWS_RETRY_MODE: standard - AWS_MAX_ATTEMPTS: 6 - run: | - aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks - aws cloudfront create-invalidation \ - --distribution-id EKT7LT5PM8RKS \ - --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" - - - name: Update Deployment Status - if: always() && steps.deployment.outputs.result - uses: actions/github-script@v8 - with: - script: | - await github.rest.repos.createDeploymentStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - deployment_id: ${{ steps.deployment.outputs.result }}, - state: "${{ steps.s3-upload.outcome == 'success' && 'success' || 'failure' }}", - environment_url: `https://docs-v3-preview.elastic.dev/${process.env.ASSEMBLER_PREVIEW_PATH_PREFIX}`, - log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - }) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index a6476c6a9..a8fc093e2 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -6,6 +6,7 @@ on: - opened - synchronize - reopened + - labeled push: branches: - main @@ -63,14 +64,14 @@ on: type: boolean default: false required: false - + permissions: contents: read deployments: write id-token: write pull-requests: write - + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }} cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }} @@ -79,7 +80,7 @@ jobs: match: if: github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks) runs-on: ubuntu-latest - permissions: + permissions: contents: none deployments: none pull-requests: none @@ -104,7 +105,7 @@ jobs: with: ref_name: ${{ steps.merge-group-base-branch.outputs.base_ref }} repository: ${{ github.repository }} - + - name: Match for PR events id: pr-check if: contains(fromJSON('["pull_request", "pull_request_target"]'), github.event_name) @@ -117,7 +118,7 @@ jobs: run: | echo "ref=${{ github.base_ref }}" echo "repo=${{ github.repository }}" - + - name: Match for push events id: push-check if: contains(fromJSON('["push"]'), github.event_name) @@ -130,7 +131,7 @@ jobs: run: | echo "ref=${{ github.ref_name }}" echo "repo=${{ github.repository }}" - + - name: Debug outputs run: | echo "content-source-match: ${{ format('{0}{1}{2}', steps.pr-check.outputs.content-source-match, steps.push-check.outputs.content-source-match, steps.merge-group-check.outputs.content-source-match) }}" @@ -141,7 +142,7 @@ jobs: check: runs-on: ubuntu-latest - needs: + needs: - match permissions: contents: read @@ -236,7 +237,7 @@ jobs: deployments: write id-token: write pull-requests: none - outputs: + outputs: deployment_result: ${{ steps.deployment.outputs.result }} path_prefix: ${{ steps.generate-path-prefix.outputs.result }} env: @@ -261,7 +262,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha || github.ref }} persist-credentials: false - + - name: Create Deployment if: > env.MATCH == 'true' @@ -408,7 +409,7 @@ jobs: ) ) uses: elastic/docs-builder/actions/validate-inbound-local@main - + - name: 'Validate inbound links' if: > env.MATCH == 'true' @@ -444,7 +445,7 @@ jobs: ) ) uses: elastic/docs-builder/actions/validate-path-prefixes-local@main - + - name: 'Validate local path prefixes against those claimed by global navigation.yml' if: > env.MATCH == 'true' @@ -516,6 +517,81 @@ jobs: environment_url: `https://docs-v3-preview.elastic.dev${process.env.LANDING_PAGE_PATH}`, log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, }) + + - name: Create Assembler Deployment + if: > + github.repository == 'elastic/docs-builder' + && steps.deployment.outputs.result + && contains(github.event.pull_request.labels.*.name, 'assembler-preview') + uses: actions/github-script@v8 + id: assembler-deployment + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + REF: ${{ github.event.pull_request.head.sha }} + with: + result-encoding: string + script: | + const { owner, repo } = context.repo; + const prNumber = process.env.PR_NUMBER; + const environment = 'assembler-preview'; + const task = `assembler-preview-${prNumber}`; + const deployment = await github.rest.repos.createDeployment({ + owner, + repo, + environment, + task, + ref: process.env.REF, + auto_merge: false, + transient_environment: true, + required_contexts: [], + }) + await github.rest.repos.createDeploymentStatus({ + deployment_id: deployment.data.id, + owner, + repo, + state: "in_progress", + log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, + }) + return deployment.data.id + + - name: Build assembled documentation + id: internal-assembler-build + if: steps.assembler-deployment.outputs.result + env: + ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} + run: | + yq -i ".environments.preview.path_prefix = \"${ASSEMBLER_PREVIEW_PATH_PREFIX}\"" config/assembler.yml + dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview + + - name: Upload assembled docs to S3 + id: assembler-s3-upload + if: steps.internal-assembler-build.outcome == 'success' + env: + AWS_RETRY_MODE: standard + AWS_MAX_ATTEMPTS: 6 + ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} + run: | + aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks + aws cloudfront create-invalidation \ + --distribution-id EKT7LT5PM8RKS \ + --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" + + - name: Update Assembler Deployment Status + if: always() && steps.assembler-deployment.outputs.result + uses: actions/github-script@v8 + env: + ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} + with: + script: | + await github.rest.repos.createDeploymentStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + deployment_id: ${{ steps.assembler-deployment.outputs.result || 0 }}, + state: "${{ steps.assembler-s3-upload.outcome == 'success' && 'success' || 'failure' }}", + environment_url: `https://docs-v3-preview.elastic.dev/${process.env.ASSEMBLER_PREVIEW_PATH_PREFIX}`, + log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, + }) + comment: if: > startsWith(github.event_name, 'pull_request') @@ -526,7 +602,7 @@ jobs: needs: - check - build - permissions: + permissions: contents: none deployments: none id-token: none @@ -619,7 +695,7 @@ jobs: const owner = context.repo.owner; const repo = context.repo.repo; - + const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: prNum }); @@ -656,7 +732,7 @@ jobs: ### 🤔 Need help? - Check out the [cumulative docs guidelines](https://www.elastic.co/docs/contribute-docs/how-to/cumulative-docs/) - Reach out in the [#docs](https://elastic.slack.com/archives/C0JF80CJZ) Slack channel`; - + await github.rest.issues.createComment({ owner, repo, issue_number: prNum, @@ -684,7 +760,7 @@ jobs: persist-credentials: false - name: Run Vale Linter uses: elastic/vale-rules/lint@main - with: + with: files: ${{ needs.check.outputs.all_changed_files }} - name: Post Vale Results uses: elastic/vale-rules/report@main From 2fd9d4ff21b8bf948b839903e4f10c4c230f74f2 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Thu, 18 Dec 2025 14:03:53 -0300 Subject: [PATCH 11/18] Revert "Create assembler deployment process" This reverts commit 71dbdaf261de3b098e91c58a9f8a661c6360e269. --- .github/workflows/preview-build.yml | 58 +++-------------------------- 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index a8fc093e2..916dce3a1 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -518,45 +518,12 @@ jobs: log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, }) - - name: Create Assembler Deployment + - name: Build assembled documentation + id: internal-assembler-build if: > github.repository == 'elastic/docs-builder' && steps.deployment.outputs.result && contains(github.event.pull_request.labels.*.name, 'assembler-preview') - uses: actions/github-script@v8 - id: assembler-deployment - env: - PR_NUMBER: ${{ github.event.pull_request.number }} - REF: ${{ github.event.pull_request.head.sha }} - with: - result-encoding: string - script: | - const { owner, repo } = context.repo; - const prNumber = process.env.PR_NUMBER; - const environment = 'assembler-preview'; - const task = `assembler-preview-${prNumber}`; - const deployment = await github.rest.repos.createDeployment({ - owner, - repo, - environment, - task, - ref: process.env.REF, - auto_merge: false, - transient_environment: true, - required_contexts: [], - }) - await github.rest.repos.createDeploymentStatus({ - deployment_id: deployment.data.id, - owner, - repo, - state: "in_progress", - log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - }) - return deployment.data.id - - - name: Build assembled documentation - id: internal-assembler-build - if: steps.assembler-deployment.outputs.result env: ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} run: | @@ -564,8 +531,9 @@ jobs: dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview - name: Upload assembled docs to S3 - id: assembler-s3-upload - if: steps.internal-assembler-build.outcome == 'success' + if: > + github.repository == 'elastic/docs-builder' + && steps.internal-assembler-build.outcome == 'success' env: AWS_RETRY_MODE: standard AWS_MAX_ATTEMPTS: 6 @@ -575,22 +543,6 @@ jobs: aws cloudfront create-invalidation \ --distribution-id EKT7LT5PM8RKS \ --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" - - - name: Update Assembler Deployment Status - if: always() && steps.assembler-deployment.outputs.result - uses: actions/github-script@v8 - env: - ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} - with: - script: | - await github.rest.repos.createDeploymentStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - deployment_id: ${{ steps.assembler-deployment.outputs.result || 0 }}, - state: "${{ steps.assembler-s3-upload.outcome == 'success' && 'success' || 'failure' }}", - environment_url: `https://docs-v3-preview.elastic.dev/${process.env.ASSEMBLER_PREVIEW_PATH_PREFIX}`, - log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - }) comment: if: > From baf4c87d5df80789a3f72764c77d510aaa353c98 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Thu, 18 Dec 2025 14:03:58 -0300 Subject: [PATCH 12/18] Revert "Remove extra slash" This reverts commit ed133bf248686253963fb69fb0637638c4affc6d. --- .github/workflows/preview-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 916dce3a1..39b5bd7df 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -537,7 +537,7 @@ jobs: env: AWS_RETRY_MODE: standard AWS_MAX_ATTEMPTS: 6 - ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} + ASSEMBLER_PREVIEW_PATH_PREFIX: /${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} run: | aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks aws cloudfront create-invalidation \ From 1b3dcaf30541302ed4769ab7abc3a434e8beec50 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Thu, 18 Dec 2025 14:04:01 -0300 Subject: [PATCH 13/18] Revert "Allow limited public assembler builds on docs-builder" This reverts commit 15e6ee59cbe8a3ad142f55a22664506bbae6da71. --- .github/workflows/preview-build.yml | 28 ---------------------------- config/assembler.yml | 8 -------- 2 files changed, 36 deletions(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 39b5bd7df..837cec41c 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -6,7 +6,6 @@ on: - opened - synchronize - reopened - - labeled push: branches: - main @@ -517,33 +516,6 @@ jobs: environment_url: `https://docs-v3-preview.elastic.dev${process.env.LANDING_PAGE_PATH}`, log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, }) - - - name: Build assembled documentation - id: internal-assembler-build - if: > - github.repository == 'elastic/docs-builder' - && steps.deployment.outputs.result - && contains(github.event.pull_request.labels.*.name, 'assembler-preview') - env: - ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} - run: | - yq -i ".environments.preview.path_prefix = \"${ASSEMBLER_PREVIEW_PATH_PREFIX}\"" config/assembler.yml - dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview - - - name: Upload assembled docs to S3 - if: > - github.repository == 'elastic/docs-builder' - && steps.internal-assembler-build.outcome == 'success' - env: - AWS_RETRY_MODE: standard - AWS_MAX_ATTEMPTS: 6 - ASSEMBLER_PREVIEW_PATH_PREFIX: /${{ github.repository }}/assembled-docs/${{ github.event.pull_request.number }} - run: | - aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks - aws cloudfront create-invalidation \ - --distribution-id EKT7LT5PM8RKS \ - --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" - comment: if: > startsWith(github.event_name, 'pull_request') diff --git a/config/assembler.yml b/config/assembler.yml index 5c9106742..40b2c7311 100644 --- a/config/assembler.yml +++ b/config/assembler.yml @@ -36,14 +36,6 @@ environments: path_prefix: docs feature_flags: SEARCH_OR_ASK_AI: true - preview: - uri: https://docs-v3-preview.elastic.dev - path_prefix: ${ASSEMBLER_PREVIEW_PATH_PREFIX} - content_source: current - google_tag_manager: - enabled: false - feature_flags: - SEARCH_OR_ASK_AI: true shared_configuration: stack: &stack From 38a1160baf22240995bc400f4bc8cd38515195c4 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Mon, 22 Dec 2025 12:26:48 -0300 Subject: [PATCH 14/18] Add workflow --- .github/workflows/assembler-preview.yml | 158 ++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 .github/workflows/assembler-preview.yml diff --git a/.github/workflows/assembler-preview.yml b/.github/workflows/assembler-preview.yml new file mode 100644 index 000000000..b409f9f53 --- /dev/null +++ b/.github/workflows/assembler-preview.yml @@ -0,0 +1,158 @@ +name: assembler-preview + +on: + pull_request: + types: + - opened + - synchronize + - reopened + - labeled + workflow_dispatch: + inputs: + pr_number: + description: 'Pull Request number to build the assembler preview for' + required: true + type: string + +permissions: + contents: read + deployments: write + id-token: write + pull-requests: read + +concurrency: + group: assembler-preview-${{ github.event.pull_request.number || inputs.pr_number }} + cancel-in-progress: true + +jobs: + build: + # Run if: + # - Manual trigger (workflow_dispatch), OR + # - PR event with 'assembler-preview' label present + if: > + github.event_name == 'workflow_dispatch' + || ( + github.event_name == 'pull_request' + && contains(github.event.pull_request.labels.*.name, 'assembler-preview') + ) + runs-on: ubuntu-latest + env: + PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} + steps: + - name: Get PR details (workflow_dispatch only) + if: github.event_name == 'workflow_dispatch' + id: pr-details + uses: actions/github-script@v8 + env: + PR_NUMBER: ${{ inputs.pr_number }} + with: + result-encoding: json + script: | + const { owner, repo } = context.repo; + const prNumber = parseInt(process.env.PR_NUMBER, 10); + + if (isNaN(prNumber) || prNumber <= 0) { + core.setFailed(`Invalid PR number: ${process.env.PR_NUMBER}`); + return; + } + + try { + const { data: pr } = await github.rest.pulls.get({ + owner, + repo, + pull_number: prNumber, + }); + + return { + sha: pr.head.sha, + ref: pr.head.ref, + base_ref: pr.base.ref, + }; + } catch (error) { + core.setFailed(`Failed to get PR #${prNumber}: ${error.message}`); + } + + - name: Set PR SHA + id: pr-sha + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "sha=${{ fromJSON(steps.pr-details.outputs.result).sha }}" >> $GITHUB_OUTPUT + else + echo "sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT + fi + + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ steps.pr-sha.outputs.sha }} + persist-credentials: false + + - name: Create Deployment + uses: actions/github-script@v8 + id: deployment + env: + PR_SHA: ${{ steps.pr-sha.outputs.sha }} + with: + result-encoding: string + script: | + const { owner, repo } = context.repo; + const prNumber = process.env.PR_NUMBER; + const environment = 'assembler-preview'; + const task = `assembler-preview-${prNumber}`; + const deployment = await github.rest.repos.createDeployment({ + owner, + repo, + environment, + task, + ref: process.env.PR_SHA, + auto_merge: false, + transient_environment: true, + required_contexts: [], + }) + await github.rest.repos.createDeploymentStatus({ + deployment_id: deployment.data.id, + owner, + repo, + state: "in_progress", + log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, + }) + return deployment.data.id + + - name: Bootstrap Action Workspace + uses: elastic/docs-builder/.github/actions/bootstrap@main + + - name: Build assembled documentation + id: assembler-build + env: + ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/docs/${{ env.PR_NUMBER }} + run: | + echo "ASSEMBLER_PREVIEW_PATH_PREFIX=${ASSEMBLER_PREVIEW_PATH_PREFIX}" >> $GITHUB_ENV + yq -i ".environments.preview.path_prefix = \"${ASSEMBLER_PREVIEW_PATH_PREFIX}\"" config/assembler.yml + dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview + + - uses: elastic/docs-builder/.github/actions/aws-auth@main + + - name: Upload assembled docs to S3 + id: s3-upload + env: + AWS_RETRY_MODE: standard + AWS_MAX_ATTEMPTS: 6 + run: | + aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks + aws cloudfront create-invalidation \ + --distribution-id EKT7LT5PM8RKS \ + --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" + + - name: Update Deployment Status + if: always() && steps.deployment.outputs.result + uses: actions/github-script@v8 + with: + script: | + await github.rest.repos.createDeploymentStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + deployment_id: ${{ steps.deployment.outputs.result }}, + state: "${{ steps.s3-upload.outcome == 'success' && 'success' || 'failure' }}", + environment_url: `https://docs-v3-preview.elastic.dev/${process.env.ASSEMBLER_PREVIEW_PATH_PREFIX}`, + log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, + }) From 11a183a50889310c77a613346b430f964807262c Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Mon, 22 Dec 2025 12:41:12 -0300 Subject: [PATCH 15/18] Remove label execution --- .github/workflows/assembler-preview.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/assembler-preview.yml b/.github/workflows/assembler-preview.yml index b409f9f53..718a92c56 100644 --- a/.github/workflows/assembler-preview.yml +++ b/.github/workflows/assembler-preview.yml @@ -6,7 +6,6 @@ on: - opened - synchronize - reopened - - labeled workflow_dispatch: inputs: pr_number: @@ -26,20 +25,13 @@ concurrency: jobs: build: - # Run if: - # - Manual trigger (workflow_dispatch), OR - # - PR event with 'assembler-preview' label present if: > github.event_name == 'workflow_dispatch' - || ( - github.event_name == 'pull_request' - && contains(github.event.pull_request.labels.*.name, 'assembler-preview') - ) runs-on: ubuntu-latest env: PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} steps: - - name: Get PR details (workflow_dispatch only) + - name: Get PR details if: github.event_name == 'workflow_dispatch' id: pr-details uses: actions/github-script@v8 From eb54ed8b3920fe3e4bde3381ef94157b7bd0c7a7 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Mon, 22 Dec 2025 12:56:38 -0300 Subject: [PATCH 16/18] Add labeled clause --- .github/workflows/assembler-preview.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/assembler-preview.yml b/.github/workflows/assembler-preview.yml index 718a92c56..364cfbcbf 100644 --- a/.github/workflows/assembler-preview.yml +++ b/.github/workflows/assembler-preview.yml @@ -6,6 +6,7 @@ on: - opened - synchronize - reopened + - labeled workflow_dispatch: inputs: pr_number: @@ -25,8 +26,6 @@ concurrency: jobs: build: - if: > - github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest env: PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} From d43f146f6709d6fcfe43d81636cd9fd3ae92ecdc Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Mon, 22 Dec 2025 13:02:29 -0300 Subject: [PATCH 17/18] Fix SHA evalutation on PRs --- .github/workflows/assembler-preview.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/assembler-preview.yml b/.github/workflows/assembler-preview.yml index 364cfbcbf..cc626e8da 100644 --- a/.github/workflows/assembler-preview.yml +++ b/.github/workflows/assembler-preview.yml @@ -63,14 +63,19 @@ jobs: core.setFailed(`Failed to get PR #${prNumber}: ${error.message}`); } - - name: Set PR SHA + - name: Set PR SHA (workflow_dispatch) + id: pr-sha-dispatch + if: github.event_name == 'workflow_dispatch' + run: echo "sha=${{ fromJSON(steps.pr-details.outputs.result).sha }}" >> $GITHUB_OUTPUT + + - name: Set PR SHA (pull_request) + id: pr-sha-pr + if: github.event_name == 'pull_request' + run: echo "sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT + + - name: Resolve PR SHA id: pr-sha - run: | - if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then - echo "sha=${{ fromJSON(steps.pr-details.outputs.result).sha }}" >> $GITHUB_OUTPUT - else - echo "sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT - fi + run: echo "sha=${{ steps.pr-sha-dispatch.outputs.sha || steps.pr-sha-pr.outputs.sha }}" >> $GITHUB_OUTPUT - name: Checkout uses: actions/checkout@v6 From 929efddbd52d30f7127bc749526990932bf5d2ab Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Mon, 22 Dec 2025 13:10:04 -0300 Subject: [PATCH 18/18] Un-revert assembler preview config --- config/assembler.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/assembler.yml b/config/assembler.yml index 40b2c7311..5c9106742 100644 --- a/config/assembler.yml +++ b/config/assembler.yml @@ -36,6 +36,14 @@ environments: path_prefix: docs feature_flags: SEARCH_OR_ASK_AI: true + preview: + uri: https://docs-v3-preview.elastic.dev + path_prefix: ${ASSEMBLER_PREVIEW_PATH_PREFIX} + content_source: current + google_tag_manager: + enabled: false + feature_flags: + SEARCH_OR_ASK_AI: true shared_configuration: stack: &stack