From c20f087ba2205d1397ee207ac2609f5dab59e72a Mon Sep 17 00:00:00 2001 From: Fabrizio Ferri Benedetti Date: Wed, 22 Jul 2026 12:47:05 +0200 Subject: [PATCH] Post blanket comment when only snippets or CSV files change When a PR edits only _snippets/ or .csv files, changedMdFiles is empty and the comment step returned silently, leaving contributors with no preview entry point. Now: detect that case and post a fallback comment under the same title (so it deduplicates correctly on re-runs) linking to the preview index. PRs that mix page and snippet changes are unaffected. Closes: elastic/docs-builder#3220 Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/docs-deploy.yml | 37 ++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index 349fec4d..0e71c15d 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -663,7 +663,42 @@ jobs: .filter(i => i.endsWith('.md')) .filter(i => !i.includes('/_snippets/')); - if (changedMdFiles.length === 0) return; + if (changedMdFiles.length === 0) { + const hasSnippetOrCsv = files + .map(f => f.filename) + .some(f => f.includes('/_snippets/') || f.endsWith('.csv')); + if (!hasSnippetOrCsv) return; + + const previewUrl = `https://docs-v3-preview.elastic.dev${process.env.PATH_PREFIX}`; + const body = [ + title, + '', + 'This PR only changes snippets or data files. No direct page links are available.', + `[Browse the full preview](${previewUrl})`, + ].join('\n'); + + const { data: comments } = await github.rest.issues.listComments({ + owner, repo, issue_number: prNumber + }); + const existing = comments.find(c => + c.user.type === 'Bot' && + c.body.startsWith(title) + ); + if (existing) { + await github.rest.issues.updateComment({ + owner, repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner, repo, + issue_number: prNumber, + body, + }); + } + return; + } const escapeMarkdown = (s) => s.replace(/([[\]()\\])/g, '\\$1'); const toMarkdownLink = (file) => {