Skip to content

Re-render rpk docs when the overrides file changes - #1863

Merged
JakeSCahill merged 1 commit into
mainfrom
ci/rerender-rpk-docs-on-overrides-change
Aug 3, 2026
Merged

Re-render rpk docs when the overrides file changes#1863
JakeSCahill merged 1 commit into
mainfrom
ci/rerender-rpk-docs-on-overrides-change

Conversation

@JakeSCahill

@JakeSCahill JakeSCahill commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What

Closes an automation gap surfaced by #1862: docs-data/rpk-overrides.json is the curated-content store for the generated rpk reference pages, but no workflow watched it. An overrides edit merged and the rendered pages kept the old content until the next release-driven regeneration, so the repo carried overrides the published docs did not reflect.

New workflow: on any push to main or beta that touches the overrides file or its schema, re-render the full rpk tree from the newest committed snapshot and open a PR with the changed pages.

Design

  • Pure re-render: doc-tools generate rpk-docs --from-json <newest snapshot> with no diff and no What's new update. No rpk binary is needed because the snapshot already carries the tree and flags, so the run takes about two minutes.
  • Snapshot selection uses the tilde-normalized sort -V (GA ranks above rc), same as the plugin receiver workflow in ci: regenerate a single rpk plugin's docs when the plugin releases #1834.
  • Bot token from Secrets Manager for PR creation so the generated PR actually runs checks (secrets.GITHUB_TOKEN PRs do not trigger Actions).
  • No loops: the workflow only watches the overrides file and its schema, and a pure re-render writes only generated pages. Re-renders that change nothing exit green without opening a PR (generation is idempotent).
  • Superseded runs are cancelled per branch rather than queued, since only the newest overrides state matters.
  • beta picks the workflow up through the regular main to beta sync.

Sequencing

Merge after redpanda-data/docs-extensions-and-macros#225 publishes doc-tools 5.3.0 (the workflow resolves @^5.3.0 at runtime), the same constraint as #1834. Once this is in, merging #1860, #1861, and #1862 automatically produces the re-render PR that brings the pages in line with the fixed overrides.

Validation

Workflow parses clean (act listing and YAML check). The generation command, snapshot resolution, idempotence, and no-changes behavior are the paths already exercised end to end in the #225 validation (18+ full regeneration rounds on a pristine clone, including repeated no-op re-renders).

Related PRs (rpk docs automation train)

See redpanda-data/docs-extensions-and-macros#225 for the train overview.

Jira

Prevention layer for DOC-2408, and part of the fix chain for DOC-2407: once merged, overrides changes like #1838 regenerate the affected pages automatically.

The overrides file is the curated-content store for generated rpk pages,
but nothing regenerated the pages when it changed: an overrides edit
merged and the rendered docs kept the old content until the next
release-driven regeneration. docs#1862 made this visible by fixing
dozens of overrides whose pages will not update until the next release
regen runs.

New workflow triggers on pushes to main or beta that touch
docs-data/rpk-overrides.json or its schema, re-renders the full rpk tree
from the newest committed snapshot (pure from-json render: no rpk
binary, no diff, no What's new), and opens a PR with the changed pages
using the actions bot token so checks run. Idempotent no-op runs exit
green without a PR, and the PR only touches generated pages so it cannot
re-trigger the workflow.
@JakeSCahill
JakeSCahill requested a review from a team as a code owner July 31, 2026 10:43
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for redpanda-docs-preview ready!

Name Link
🔨 Latest commit 8514f2b
🔍 Latest deploy log https://app.netlify.com/projects/redpanda-docs-preview/deploys/6a6c7c54637a4d0008bf5df4
😎 Deploy Preview https://deploy-preview-1863--redpanda-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The workflow runs when RPK override files change on main or beta, or when manually dispatched. It selects the newest eligible RPK snapshot, renders documentation, and checks for generated changes. If changes exist, it authenticates with AWS, retrieves a bot token, generates the pull-request body, and opens a rerender pull request. Unchanged renders stop without creating a pull request.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant SnapshotResolver
  participant RPKDocumentationGenerator
  participant GitHub
  GitHubActions->>SnapshotResolver: select newest non-diff RPK snapshot
  SnapshotResolver-->>GitHubActions: return selected snapshot
  GitHubActions->>RPKDocumentationGenerator: render documentation
  RPKDocumentationGenerator-->>GitHubActions: generated files
  GitHubActions->>GitHub: detect changes
  alt Generated files changed
    GitHubActions->>GitHub: authenticate and create pull request
  else No generated changes
    GitHubActions-->>GitHubActions: exit without pull request
  end
Loading

Possibly related PRs

Suggested reviewers: kbatuigas

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly states that the workflow re-renders RPK documentation when the overrides file changes.
Description check ✅ Passed The description clearly explains the workflow purpose, design, sequencing, validation, and Jira context, although it omits several template sections.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/rerender-rpk-docs-on-overrides-change

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/rerender-rpk-docs-on-overrides-change.yml (1)

68-68: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Pin the generator to an exact version.

^5.3.0 can resolve to a later 5.x release, so the same overridden config can generate different RPK docs after a dependency update. Use the exact generator version, such as 5.3.0.

Proposed fix
-          npx --yes -p `@redpanda-data/docs-extensions-and-macros`@^5.3.0 doc-tools generate rpk-docs \
+          npx --yes -p `@redpanda-data/docs-extensions-and-macros`@5.3.0 doc-tools generate rpk-docs \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/rerender-rpk-docs-on-overrides-change.yml at line 68,
Update the doc-tools generator invocation to pin
`@redpanda-data/docs-extensions-and-macros` to the exact 5.3.0 version instead of
using the ^5.3.0 range, while leaving the rpk-docs generation command unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/rerender-rpk-docs-on-overrides-change.yml:
- Around line 69-70: Update
.github/workflows/rerender-rpk-docs-on-overrides-change.yml lines 69-70 to pass
steps.snapshot.outputs.snapshot through the step environment and use the quoted
SNAPSHOT variable for --from-json. Also update lines 100-106 to use the quoted
GITHUB_REF_NAME and GITHUB_SHA environment variables with printf instead of
embedding GitHub expressions in the shell script.

---

Nitpick comments:
In @.github/workflows/rerender-rpk-docs-on-overrides-change.yml:
- Line 68: Update the doc-tools generator invocation to pin
`@redpanda-data/docs-extensions-and-macros` to the exact 5.3.0 version instead of
using the ^5.3.0 range, while leaving the rpk-docs generation command unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e2b4ec98-b831-41ab-83e5-fdc000fc087a

📥 Commits

Reviewing files that changed from the base of the PR and between 1c0559d and 8514f2b.

📒 Files selected for processing (1)
  • .github/workflows/rerender-rpk-docs-on-overrides-change.yml

Comment on lines +69 to +70
--from-json "${{ steps.snapshot.outputs.snapshot }}" \
--summary-file /tmp/pr-summary.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Pass expression values through environment variables, not shell templates. GitHub expands expressions before Bash parses the script. This lets repository-derived or dispatch-derived values become shell syntax.

  • .github/workflows/rerender-rpk-docs-on-overrides-change.yml#L69-L70: pass steps.snapshot.outputs.snapshot through env and use "$SNAPSHOT".
  • .github/workflows/rerender-rpk-docs-on-overrides-change.yml#L100-L106: use "$GITHUB_REF_NAME" and "$GITHUB_SHA" with printf.
Proposed fix
       - name: Re-render rpk docs
+        env:
+          SNAPSHOT: ${{ steps.snapshot.outputs.snapshot }}
         run: |
           npx --yes -p `@redpanda-data/docs-extensions-and-macros`@^5.3.0 doc-tools generate rpk-docs \
-            --from-json "${{ steps.snapshot.outputs.snapshot }}" \
+            --from-json "$SNAPSHOT" \
             --summary-file /tmp/pr-summary.md
           {
-            echo "Automated re-render of the generated rpk reference pages after an overrides change on \`${{ github.ref_name }}\` (${{ github.sha }})."
+            printf 'Automated re-render of the generated rpk reference pages after an overrides change on `%s` (%s).\n' \
+              "$GITHUB_REF_NAME" "$GITHUB_SHA"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--from-json "${{ steps.snapshot.outputs.snapshot }}" \
--summary-file /tmp/pr-summary.md
- name: Re-render rpk docs
env:
SNAPSHOT: ${{ steps.snapshot.outputs.snapshot }}
run: |
npx --yes -p `@redpanda-data/docs-extensions-and-macros`@^5.3.0 doc-tools generate rpk-docs \
--from-json "$SNAPSHOT" \
--summary-file /tmp/pr-summary.md
Suggested change
--from-json "${{ steps.snapshot.outputs.snapshot }}" \
--summary-file /tmp/pr-summary.md
{
printf 'Automated re-render of the generated rpk reference pages after an overrides change on `%s` (%s).\n' \
"$GITHUB_REF_NAME" "$GITHUB_SHA"
echo
echo "Review focus: the changed pages should reflect exactly the merged overrides edit, nothing else. The generator version is pinned to the same range the release regeneration uses, so unrelated churn here means the branch missed a regeneration and this PR is catching it up."
echo
cat /tmp/pr-summary.md 2>/dev/null || true
🧰 Tools
🪛 zizmor (1.28.0)

[info] 69-69: code injection via template expansion (template-injection): may expand into attacker-controllable code

(template-injection)

📍 Affects 1 file
  • .github/workflows/rerender-rpk-docs-on-overrides-change.yml#L69-L70 (this comment)
  • .github/workflows/rerender-rpk-docs-on-overrides-change.yml#L100-L106
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/rerender-rpk-docs-on-overrides-change.yml around lines 69
- 70, Update .github/workflows/rerender-rpk-docs-on-overrides-change.yml lines
69-70 to pass steps.snapshot.outputs.snapshot through the step environment and
use the quoted SNAPSHOT variable for --from-json. Also update lines 100-106 to
use the quoted GITHUB_REF_NAME and GITHUB_SHA environment variables with printf
instead of embedding GitHub expressions in the shell script.

Source: Linters/SAST tools

@micheleRP micheleRP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the mechanism, with one ordering requirement that I would treat as a merge gate rather than a nicety.

This workflow must merge after #1865, not before. It runs --from-json, so it never installs a plugin and never extracts flags. Combined with #1865 that is a live regression on the published rpk connect run page.

The chain, all verified with the published 5.3.1 against main plus the three merged overrides PRs:

  • The committed snapshot has rpk connect run with 0 flags. Connect flag data only exists via live extraction.
  • Until now that was masked: the override carried a hand-written 7-row Flags table that rendered unconditionally. #1865 removes it, correctly, because #225 made the extracted table authoritative.
  • So a --from-json regeneration today renders that page with no Flags section at all: Usage straight to Global flags. Not a stale table, no table.

Which means: merge #1865 while this is live, the overrides change triggers a re-render, and the page silently loses its flag documentation.

The mitigation works, and it is just sequencing:

--plugin connect --rpk-bin   ->  Extracted flags for 16 command(s)
                             ->  Saved versioned JSON to docs-data/rpk-v26.2.1-rc2.json
                             ->  snapshot connect run flags: 13
then --from-json             ->  Flags sections: 1, rows: 13

So once the re-dispatch has persisted extracted connect flags into the committed snapshot, from-json regeneration is safe and this workflow is fine. Concretely, before merging #1865 or this, confirm the committed docs-data/rpk-v26.2.1-rc2.json has 13 flags on rpk connect run.

Suggested follow-up in the generator: nothing catches this class today. A command that rendered flags previously and now renders none is almost always a data problem, not a real change. A warning on a nonzero-to-zero flag-count transition would have surfaced this before it reached a page, and it generalizes to any plugin family whose flags come only from extraction.

Ordering, tested

Four open PRs edit rpk-overrides.json. I test-merged all pairs: #1838, #1860, and #1865 are mutually clean in any order, and only #1862 conflicts, with both #1838 and #1865, in either direction. Running #1838 then #1860 then #1865 as a real sequence is clean, leaves valid JSON, and produces all four intended effects at once.

So: re-dispatch, confirm the snapshot has connect flags, then #1860 and #1865, then this, then rebase #1862.

@micheleRP

Copy link
Copy Markdown
Contributor

Follow-up: the ordering requirement in my review has now been independently re-verified in a fresh pass, link by link from primary sources rather than from my earlier notes, and it holds — with two refinements that sharpen the merge gate.

Re-verified on a confirmed-pristine checkout of current main plus the merged overrides PRs: the committed snapshot's connect subtree has zero flags everywhere (plugin_versions lists only ai, spliced by #1868; connect has never been spliced), this workflow is a pure --from-json re-render per its own header comment, and the regeneration renders rpk connect run as title → Usage → Global flags with no Flags section and zero warnings — the failure is completely silent at generation time.

The two refinements:

  1. The pre-merge check targets the newest snapshot, not a specific file. This workflow resolves the newest rpk-v*.json via the tilde-normalized sort. After the v26.2.1 re-dispatch, that is the new rpk-v26.2.1.json, not the current rc2 file. And the gate is the re-dispatch auto-PR merging (which lands the connect-enriched snapshot on main), not the dispatch having been fired. Concretely: before docs: clean up stale rpk command overrides #1865 and this merge, node -e over whichever snapshot the sort selects must show 13 flags on rpk connect run.
  2. Severity nuance: because this opens a PR rather than pushing, a reviewer could catch the vanished section — but arriving right after docs: clean up stale rpk command overrides #1865 removes the redundant curated table, a missing Flags section reads as intended cleanup. Semi-silent rather than zero-contact, which is still not a safety net worth relying on.

The nonzero-to-zero flag-count warning suggested earlier now has direct evidence behind it: the log for the failing case contains zero errors and zero warnings.

@JakeSCahill
JakeSCahill merged commit fb733e7 into main Aug 3, 2026
8 checks passed
@JakeSCahill
JakeSCahill deleted the ci/rerender-rpk-docs-on-overrides-change branch August 3, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants