Skip to content

Create release docs automation#8925

Open
amyblais wants to merge 22 commits into
masterfrom
amyblais-releasedocsautomation
Open

Create release docs automation#8925
amyblais wants to merge 22 commits into
masterfrom
amyblais-releasedocsautomation

Conversation

@amyblais
Copy link
Copy Markdown
Member

@amyblais amyblais commented Apr 30, 2026

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:

  • Component — Server, Mobile, or Desktop
  • Release type — ESR, Feature Release, Security Release, Patch/Dot Release, or Other
  • Version — e.g. 11.7, 2.40, 6.2
  • Release date — e.g. May 15, 2026
  • Additional instructions (optional) — any extra context like an ESR end-of-support date

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.

Copilot AI review requested due to automatic review settings April 30, 2026 10:29
@amyblais amyblais added the Work In Progress Not yet ready for review label Apr 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_dispatch workflow 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.

Comment thread .github/workflows/update-docs.yml
Comment thread .github/workflows/update-docs.yml Outdated
Comment thread .github/workflows/update-docs.yml Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA bf7c558

amyblais and others added 2 commits April 30, 2026 13:33
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>
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 836a331

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow and a Python script that use Anthropic’s Messages API to regenerate selected docs from release metadata with truncation handling, response validation, write-safety guards, branch/PR creation, and per-file status reporting.

Changes

Automated Documentation Updates

Layer / File(s) Summary
Environment & configuration
.github/scripts/update_docs.py
Adds top-level script documentation and environment-driven constants (COMPONENT, RELEASE_TYPE, VERSION, RELEASE_DATE, ESR_END_DATE, MAX_TOKENS, MAX_SEND_CHARS).
File lists & selection
.github/scripts/update_docs.py
Defines per-component/per-release file lists and get_files() selection; exits with status 1 on unknown component.
Prompt templates
.github/scripts/update_docs.py
Adds fixed SYSTEM_PROMPT and build_user_prompt(filepath, content) embedding release metadata and original file content into the user message.
API call & update logic
.github/scripts/update_docs.py
update_file() reads/truncates large files, calls anthropic.Anthropic.messages.create(...), enforces response shape and stop_reason handling, applies no-op/quality guards (empty output, <50% length, unchanged), reconstructs truncated outputs, overwrites files when accepted, and returns a per-file status string.
Orchestration & CLI entry
.github/scripts/update_docs.py
main() builds the Anthropic client from ANTHROPIC_API_KEY, enumerates files from get_files(), processes each file collecting statuses/exceptions, prints a summary, and exits non-zero if any file failed; includes __main__ entrypoint.
Workflow trigger, runner & PR creation
.github/workflows/update-docs.yml
Adds workflow_dispatch inputs (component, release_type, version, release_date, optional esr_end_date, pr_draft), sets env vars for the script, installs anthropic, runs the script, sanitizes version to safe_version, commits/pushes docs branch only when source/ changes, and conditionally creates a PR (avoids duplicate PRs, supports draft and ESR text).

Sequence Diagram

sequenceDiagram
    actor User
    participant GitHub as GitHub Actions
    participant Runner as update-docs job
    participant Script as update_docs.py
    participant Anthropic as Anthropic API
    participant FileSystem as File System
    participant Git as git/gh

    User->>GitHub: Trigger workflow_dispatch (component, version, release_type, etc.)
    GitHub->>Runner: Checkout repo, setup Python, install anthropic
    Runner->>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 and stop_reason
        Script->>Script: Validate (structure, stop_reason, non-empty, length >=50%, changed)
        Script->>FileSystem: Write updated file (if safe)
    end
    Script-->>Git: Commit & push branch docs/{component}-v{safe_version} (if changes)
    Git->>GitHub: Create PR via gh pr create (if no existing PR)
    Git-->>User: PR created (draft or ready)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Create release docs automation' clearly and concisely describes the main change—adding GitHub Actions workflow automation for documentation updates.
Description check ✅ Passed The description provides detailed context about the automation added, explaining what the workflow does, how it works, and why it improves the release process.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch amyblais-releasedocsautomation

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 2eed2fe

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA cb4dc94

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Newest code from mattermost has been published to preview environment for Git SHA 8b3f734

@amyblais amyblais added 1: Dev Review Requires review by a core commiter and removed Work In Progress Not yet ready for review labels May 5, 2026
@amyblais amyblais requested review from NARSimoes and esarafianou May 5, 2026 10:16
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/update-docs.yml (1)

58-59: ⚡ Quick win

Pin the Anthropic SDK version for reproducible workflow runs.

Installing anthropic without 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

📥 Commits

Reviewing files that changed from the base of the PR and between 560c09f and 8b3f734.

📒 Files selected for processing (2)
  • .github/scripts/update_docs.py
  • .github/workflows/update-docs.yml

Comment thread .github/scripts/update_docs.py Outdated
Comment thread .github/scripts/update_docs.py
Comment thread .github/workflows/update-docs.yml Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Newest code from mattermost has been published to preview environment for Git SHA 36da96b

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Newest code from mattermost has been published to preview environment for Git SHA 121da36

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Newest code from mattermost has been published to preview environment for Git SHA 25408b2

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/scripts/update_docs.py (1)

28-32: 💤 Low value

Bare os.environ[...] at module scope emits a cryptic KeyError when a required variable is absent.

A missing COMPONENT or VERSION raises KeyError: 'COMPONENT' with no indication that this is a required workflow input. A small validation block early in main() (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

📥 Commits

Reviewing files that changed from the base of the PR and between 8b3f734 and 25408b2.

📒 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

Comment thread .github/scripts/update_docs.py
Comment thread .github/scripts/update_docs.py
Comment thread .github/scripts/update_docs.py Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/update-docs.yml:
- Around line 58-60: The workflow step named "Install dependencies" uses an
unpinned run command `pip install anthropic`; change this to install a pinned
anthropic version (e.g., pin to a specific semantic version) to ensure
deterministic CI, and apply the same pinning to the identical `pip install
anthropic` steps in `generate-changelog.yml` and `pr-export.yml`; update the run
command in the "Install dependencies" step that currently contains `pip install
anthropic` to use the fixed version string instead.
🪄 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: d630a996-a9e9-420c-9e89-71700d3b5a28

📥 Commits

Reviewing files that changed from the base of the PR and between 25408b2 and d926a21.

📒 Files selected for processing (2)
  • .github/scripts/update_docs.py
  • .github/workflows/update-docs.yml

Comment thread .github/workflows/update-docs.yml
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA d926a21

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 6896d53

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 7947f50

@Combs7th
Copy link
Copy Markdown
Contributor

@NARSimoes @esarafianou - Are y'all able to help give this a dev review?

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 8b98b8d

Copy link
Copy Markdown
Contributor

@NARSimoes NARSimoes left a comment

Choose a reason for hiding this comment

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

Thanks @amyblais, added a few comments / clarifications.

Comment thread .github/workflows/update-docs.yml Outdated
Comment thread .github/workflows/update-docs.yml Outdated
Comment thread .github/workflows/update-docs.yml Outdated
description: 'Release date (e.g., May 15, 2026)'
required: true
type: string
instructions:
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.

What additional instruction are we planning to add? I wonder if we should strict the input instructions since current approach is a free form and inject anything to the model prompt.

Copy link
Copy Markdown
Member Author

@amyblais amyblais May 21, 2026

Choose a reason for hiding this comment

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

Addressed! Updated the description to "Keep concise — appended to the Claude prompt as-is" so it's clear what it does and nudges users toward short, specific input rather than arbitrary text.

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.

Thank you @amyblais, What additional instruction are we planning to add? Just trying to understand if we really need this or we can think about an alternative to avoid having a free form that allow injecting anything to the models.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Replaced free-form instructions with a structured esr_end_date input (covers the known use case without the injection risk).

Comment thread .github/workflows/update-docs.yml
Comment thread .github/scripts/update_docs.py Outdated
Comment thread .github/scripts/update_docs.py Outdated
Comment thread .github/scripts/update_docs.py Outdated
Comment thread .github/scripts/update_docs.py Outdated
Comment thread .github/scripts/update_docs.py
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA c467bef

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA c46f9fb

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 2958bad

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA a0e1d4f

@amyblais amyblais requested a review from NARSimoes May 21, 2026 09:48
Copy link
Copy Markdown
Contributor

@NARSimoes NARSimoes left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the review, a few more clarifications.

Comment thread .github/workflows/update-docs.yml Outdated
echo "Please review all changes carefully before merging."
} > pr_body.md

gh pr create \
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.

Consider adding --base / --head branch. For example in generate-changelog we use

            --base master \
            --head "changelog/${{ inputs.version }}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added --base/--head to gh pr create.

Comment thread .github/workflows/update-docs.yml Outdated
echo "No files were modified — skipping PR creation."
else
git commit -m "docs: update ${{ inputs.component }} files for v${{ inputs.version }} ${{ inputs.release_type }}"
git push origin "docs/${{ inputs.component }}-v${{ steps.vars.outputs.safe_version }}"
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.

We might have some collisions here if we are planning to re-run this for same component / version. For example if the pull requests already exists or content already pushed. One possible option could be --force-with-release but would need to double check.

# Create new branch e.g. docs/server-v17
git checkout -b "docs/${{ inputs.component }}-v${{ steps.vars.outputs.safe_version }}"
...
# Push to e.g. docs/server-v17
git push origin "docs/${{ inputs.component }}-v${{ steps.vars.outputs.safe_version }}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed - using git push --force-with-lease and check if a PR already exists before creating.

Comment thread .github/scripts/update_docs.py Outdated
print(f" {fp}: {err}")
sys.exit(1)
else:
print("All files processed successfully.")
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.

Clarification: there are files being skipped just printing messages with Warnings / Errors and here it's printing All files processed successfully.. Is this expected?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Refactored update_file() to return a status, and print an accurate summary that distinguishes updated/unchanged/skipped/not-found.

Comment thread .github/scripts/update_docs.py Outdated
# ---------------------------------------------------------------------------

SERVER_FILES = [
"source/product-overview/mattermost-v11-changelog.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.

I wonder if this file is too heavy. If we are only interested in the ~ < 50 % of the file we could find some strategy to reduce the size of (e.g. just send part of the file, etc). Open for discussion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed from the list as we have a separate automation for the server changelog.

Comment thread .github/workflows/update-docs.yml Outdated
description: 'Release date (e.g., May 15, 2026)'
required: true
type: string
instructions:
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.

Thank you @amyblais, What additional instruction are we planning to add? Just trying to understand if we really need this or we can think about an alternative to avoid having a free form that allow injecting anything to the models.

@amyblais amyblais requested a review from NARSimoes May 22, 2026 09:27
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 46c0a09

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 68ef475

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.github/workflows/update-docs.yml (1)

93-93: ⚡ Quick win

Use environment variable for inputs.version in commit message to avoid template injection.

While inputs.component and inputs.release_type are choice inputs (safe), inputs.version is a free-form string. Direct interpolation in a shell command can allow injection if the value contains shell metacharacters. The risk is mitigated by the write-access requirement, but using an environment variable is a low-effort hardening.

Suggested fix
       - name: Commit and push changes
         id: commit
+        env:
+          VERSION: ${{ inputs.version }}
         run: |
           git config user.name "github-actions[bot]"
           git config user.email "github-actions[bot]`@users.noreply.github.com`"
           git checkout -b "docs/${{ inputs.component }}-v${{ steps.vars.outputs.safe_version }}"
           git add source/
           if git diff --cached --quiet; then
             echo "changed=false" >> "$GITHUB_OUTPUT"
             echo "No files were modified — skipping PR creation."
           else
-            git commit -m "docs: update ${{ inputs.component }} files for v${{ inputs.version }} ${{ inputs.release_type }}"
+            git commit -m "docs: update ${{ inputs.component }} files for v${VERSION} ${{ inputs.release_type }}"
             # --force-with-lease safely overwrites the remote branch on re-runs
             # without clobbering any concurrent pushes from other users.
             git push --force-with-lease origin "docs/${{ inputs.component }}-v${{ steps.vars.outputs.safe_version }}"
             echo "changed=true" >> "$GITHUB_OUTPUT"
           fi
🤖 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 at line 93, The commit command directly
interpolates inputs.version into a shell command (git commit -m "...${{
inputs.version }}..."), which can allow shell injection; instead, set an
environment variable (e.g., VERSION) to ${{ inputs.version }} in the workflow
step or job env and change the git commit invocation to reference that env var
(use $VERSION) while leaving ${{ inputs.component }} and ${{ inputs.release_type
}} as-is; update the step that contains the git commit -m line to read the
environment variable instead of interpolating inputs.version inline.
🤖 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.

Nitpick comments:
In @.github/workflows/update-docs.yml:
- Line 93: The commit command directly interpolates inputs.version into a shell
command (git commit -m "...${{ inputs.version }}..."), which can allow shell
injection; instead, set an environment variable (e.g., VERSION) to ${{
inputs.version }} in the workflow step or job env and change the git commit
invocation to reference that env var (use $VERSION) while leaving ${{
inputs.component }} and ${{ inputs.release_type }} as-is; update the step that
contains the git commit -m line to read the environment variable instead of
interpolating inputs.version inline.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b3e26d8-240e-4cdb-a19c-fffca260e3cb

📥 Commits

Reviewing files that changed from the base of the PR and between 7947f50 and edb07de.

📒 Files selected for processing (2)
  • .github/scripts/update_docs.py
  • .github/workflows/update-docs.yml

@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA edb07de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1: Dev Review Requires review by a core commiter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants