Conversation
There was a problem hiding this comment.
Pull request overview
Adds a manually triggered GitHub Actions workflow intended to automate release documentation updates by running a Python script and opening a PR in this docs repository.
Changes:
- Introduces a new
workflow_dispatchworkflow with inputs (component, release type, version, release date, instructions, draft PR). - Sets up Python, installs the Anthropic SDK, runs a docs update script, and opens a PR via
peter-evans/create-pull-request.
|
Newest code from mattermost has been published to preview environment for Git SHA bf7c558 |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Newest code from mattermost has been published to preview environment for Git SHA 836a331 |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a workflow and Python script that read release metadata, regenerate selected docs via the Anthropic Messages API with safety checks, and create a pull request with the updates. ChangesAutomated Documentation Updates
Sequence DiagramsequenceDiagram
actor User
participant GitHub as GitHub Actions
participant Script as update_docs.py
participant Anthropic as Anthropic API
participant FileSystem as File System
User->>GitHub: Trigger workflow_dispatch (component, version, release_type, etc.)
GitHub->>GitHub: Checkout repo, setup Python, install anthropic
GitHub->>Script: Run with env vars (ANTHROPIC_API_KEY, metadata)
Script->>Script: get_files()
loop For each documentation file
Script->>FileSystem: Read file content
Script->>Script: Build user prompt (metadata + content)
Script->>Anthropic: Call Messages API (system + user prompt)
Anthropic-->>Script: Return response.content[0].text
Script->>Script: Validate (non-empty, length >=50%, changed)
Script->>FileSystem: Write updated file (if safe)
end
Script-->>GitHub: Exit status
GitHub->>GitHub: Create PR docs/{component}-v{safe_version}
GitHub-->>User: PR created (draft or ready)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Newest code from mattermost has been published to preview environment for Git SHA 2eed2fe |
|
Newest code from mattermost has been published to preview environment for Git SHA cb4dc94 |
|
Newest code from mattermost has been published to preview environment for Git SHA 8b3f734 |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
.github/workflows/update-docs.yml (1)
58-59: ⚡ Quick winPin the Anthropic SDK version for reproducible workflow runs.
Installing
anthropicwithout a version can pull breaking changes and make the automation flaky over time. The latest stable version is 0.97.0 and is compatible with Python 3.11.Suggested fix
- - name: Install dependencies - run: pip install anthropic + - name: Install dependencies + run: pip install -r .github/scripts/update-docs-requirements.txt# .github/scripts/update-docs-requirements.txt anthropic==0.97.0🤖 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/update-docs.yml around lines 58 - 59, Replace the unpinned pip install in the "Install dependencies" workflow step by pinning the Anthropic SDK to 0.97.0: create a requirements file named .github/scripts/update-docs-requirements.txt containing anthopic==0.97.0 and change the step that currently runs "pip install anthropic" to "pip install -r .github/scripts/update-docs-requirements.txt" so the workflow uses the fixed anthropic==0.97.0 release for reproducible runs.
🤖 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/scripts/update_docs.py:
- Around line 138-140: The current handlers in update_docs.py (including the
except FileNotFoundError block and the other early-return sites around where
errors/warnings are logged) log problems then return, allowing main() to exit
success; change those returns to fail-fast behavior by raising or exiting
non‑zero (e.g., raise RuntimeError or call sys.exit(1)) so the workflow fails
when safety checks reject an update; update the except FileNotFoundError handler
and the two locations that log error/warning (the blocks referenced around lines
152–163) to propagate a non‑zero failure instead of returning normally.
- Line 142: The print statements using f-strings with no placeholders (e.g.,
print(f" Sending to Claude...") and the similar print at line 183) should be
converted to plain strings; locate the print calls in update_docs.py (look for
the exact message " Sending to Claude..." and the other analogous message) and
change them from f-strings to normal string literals (remove the leading f) so
they are simple print(" Sending to Claude...") calls.
In @.github/workflows/update-docs.yml:
- Line 75: Sanitize the free-form inputs.version before using it in the branch
ref: replace or remove characters that can make invalid Git branch names
(spaces, slashes, colons, parentheses, and other non-alphanumeric characters
except dot and dash), collapse consecutive separators to a single dash, trim
leading/trailing separators, and normalize case; then use that sanitized value
instead of inputs.version in the branch expression (replace branch: docs/${{
inputs.component }}-v${{ inputs.version }} with branch: docs/${{
inputs.component }}-v${{ steps.sanitize-version.outputs.version }} and add a
short step named sanitize-version that computes and outputs the cleaned version
string).
---
Nitpick comments:
In @.github/workflows/update-docs.yml:
- Around line 58-59: Replace the unpinned pip install in the "Install
dependencies" workflow step by pinning the Anthropic SDK to 0.97.0: create a
requirements file named .github/scripts/update-docs-requirements.txt containing
anthopic==0.97.0 and change the step that currently runs "pip install anthropic"
to "pip install -r .github/scripts/update-docs-requirements.txt" so the workflow
uses the fixed anthropic==0.97.0 release for reproducible runs.
🪄 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
Run ID: dde1a4b0-2311-4c59-9766-35b752c87527
📒 Files selected for processing (2)
.github/scripts/update_docs.py.github/workflows/update-docs.yml
|
Newest code from mattermost has been published to preview environment for Git SHA 36da96b |
|
Newest code from mattermost has been published to preview environment for Git SHA 121da36 |
|
Newest code from mattermost has been published to preview environment for Git SHA 25408b2 |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
.github/scripts/update_docs.py (1)
28-32: 💤 Low valueBare
os.environ[...]at module scope emits a crypticKeyErrorwhen a required variable is absent.A missing
COMPONENTorVERSIONraisesKeyError: 'COMPONENT'with no indication that this is a required workflow input. A small validation block early inmain()(or a helper) would provide an actionable error message and keep side-effects out of module initialisation.♻️ Proposed refactor
-COMPONENT = os.environ["COMPONENT"] -RELEASE_TYPE = os.environ["RELEASE_TYPE"] -VERSION = os.environ["VERSION"] -RELEASE_DATE = os.environ["RELEASE_DATE"] -INSTRUCTIONS = os.environ.get("INSTRUCTIONS", "").strip() +def _require_env(name: str) -> str: + value = os.environ.get(name) + if not value: + print(f"ERROR: Required environment variable '{name}' is not set.") + sys.exit(1) + return value + +COMPONENT = _require_env("COMPONENT") +RELEASE_TYPE = _require_env("RELEASE_TYPE") +VERSION = _require_env("VERSION") +RELEASE_DATE = _require_env("RELEASE_DATE") +INSTRUCTIONS = os.environ.get("INSTRUCTIONS", "").strip()🤖 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/scripts/update_docs.py around lines 28 - 32, Move environment access out of module scope and add explicit validation: stop reading COMPONENT, RELEASE_TYPE, VERSION, RELEASE_DATE, and INSTRUCTIONS at import time and instead read them inside main() (or a new helper like validate_env_vars()) and raise a clear RuntimeError or print an actionable message if any required variable (COMPONENT, VERSION, RELEASE_DATE) is missing; keep optional INSTRUCTIONS using os.environ.get(...).strip() inside the same helper, and update any references to use the local variables returned by main()/validate_env_vars() so module import no longer raises KeyError.
🤖 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/scripts/update_docs.py:
- Around line 196-200: The try/except around update_file(client, filepath)
currently catches all Exception; change it to only catch expected recoverable
errors (e.g., OSError, anthropic.APIError, RuntimeError) and let fatal errors
propagate; update the except handler for the tuple (OSError, anthropic.APIError,
RuntimeError) to log the exception type and message (including type(e).__name__)
and append to errors as before, and remove or avoid a broad except Exception so
functions like update_file, client, or filepath-related fatal exceptions bubble
up instead of being swallowed.
- Around line 142-149: Guard against empty/invalid response.content and detect
truncated outputs before writing files: after calling client.messages.create
(the response object used as response.content[0].text), verify response.content
is a non-empty list and that response.content[0] has a text field (and/or type
== "text") before accessing .text to avoid IndexError/AttributeError;
additionally check response.stop_reason and refuse to accept outputs where
stop_reason == "max_tokens" (or any non-null truncation indicator) — in that
case either retry with a larger/max_tokens or surface an explicit error so the
file is not overwritten with truncated content; make max_tokens configurable
(e.g., increase to 32000) if needed and ensure any early-return paths raise or
log a clear error rather than letting the broad except() silently skip writing.
- Around line 42-69: SERVER_FILES currently includes
"source/product-overview/mattermost-desktop-releases.md" which should not be
updated for Server releases; remove that string from the SERVER_FILES list so it
only exists in DESKTOP_BASE_FILES, i.e., edit the SERVER_FILES definition to
delete the "source/product-overview/mattermost-desktop-releases.md" entry and
leave DESKTOP_BASE_FILES unchanged.
---
Nitpick comments:
In @.github/scripts/update_docs.py:
- Around line 28-32: Move environment access out of module scope and add
explicit validation: stop reading COMPONENT, RELEASE_TYPE, VERSION,
RELEASE_DATE, and INSTRUCTIONS at import time and instead read them inside
main() (or a new helper like validate_env_vars()) and raise a clear RuntimeError
or print an actionable message if any required variable (COMPONENT, VERSION,
RELEASE_DATE) is missing; keep optional INSTRUCTIONS using
os.environ.get(...).strip() inside the same helper, and update any references to
use the local variables returned by main()/validate_env_vars() so module import
no longer raises KeyError.
🪄 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
Run ID: 28615292-da7e-4fa9-9990-46d9386a94cb
📒 Files selected for processing (2)
.github/scripts/update_docs.py.github/workflows/update-docs.yml
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/update-docs.yml
|
Newest code from mattermost has been published to preview environment for Git SHA 98a634c |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
Newest code from mattermost has been published to preview environment for Git SHA 7972411 |
|
Newest code from mattermost has been published to preview environment for Git SHA 518d76f |
|
@coderabbitai resolve |
✅ Actions performedComments resolved and changes approved. |
Full spec doc: https://mattermost.atlassian.net/wiki/spaces/Security/pages/4518772760/Automation+-+Release+Docs+Update+GitHub+Actions+Workflow.
Adds a GitHub Actions workflow that automates docs updates for Mattermost releases. Instead of manually opening a GitHub issue, tagging claude, and pasting file URLs each time, you go to Actions → Update Docs → Run workflow and fill in four fields:
The workflow then automatically selects the right set of files for that component and release type, sends each one to Claude via the Anthropic API with the release context, and opens a PR with all the updated files — no issue, no copy-pasting URLs, no manual file list.