Skip to content

Conversation

@derberg
Copy link
Member

@derberg derberg commented Oct 24, 2025

Resolves #2064

this might not work the first time, no way for me to test it elsewhere

Summary by CodeRabbit

  • New Features
    • Automatically generates a draft website preview for pull requests that change documentation and posts the preview URL as a comment on the PR.
  • Chores
    • Adds CI workflow to build and deploy documentation previews so contributors can review doc changes before merge.

@coderabbitai
Copy link

coderabbitai bot commented Oct 24, 2025

Walkthrough

A new GitHub Actions workflow is added that triggers on pull requests affecting docs, checks out the contributor PR and the asyncapi/website repo, syncs docs, builds the site with Node.js 20, deploys a draft Netlify preview, captures the deploy URL, and comments the preview link on the PR.

Changes

Cohort / File(s) Summary
Netlify preview workflow
​.github/workflows/manual-netlify-preview.yml
New GitHub Actions workflow that checks out the contributor PR and the asyncapi/website repo, syncs docs into the website, sets up Node.js 20, installs dependencies and Netlify CLI (and jq), builds the site, deploys a draft Netlify preview, captures the preview URL as workflow output, and posts a comment with the preview URL on the PR.

Sequence Diagram

sequenceDiagram
    actor Developer
    participant PR as GitHub (Pull Request)
    participant Workflow as GitHub Actions (manual-netlify-preview)
    participant Runner as Runner / Build Env
    participant Website as asyncapi/website (repo)
    participant Netlify as Netlify

    Developer->>PR: Open/update PR affecting docs
    PR->>Workflow: Trigger job
    Workflow->>Runner: Checkout contributor PR
    Workflow->>Runner: Checkout Website repo
    Runner->>Website: Sync docs from PR -> website content
    Runner->>Runner: Setup Node.js 20, install deps, Netlify CLI, jq
    Runner->>Runner: Build website
    Runner->>Netlify: Deploy draft preview (publish folder)
    Netlify-->>Runner: Return preview URL
    Runner->>Workflow: Set workflow output (preview_url)
    Workflow->>PR: Post PR comment with preview URL
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Potential attention points:

  • Review secrets/permissions use for checking out and pushing into the website repo.
  • Confirm Netlify CLI invocation and draft deploy flags match desired behavior.
  • Validate the docs sync step correctly preserves paths and metadata.

Poem

🐰 I hopped through branches, docs in my paw,
I built every page with a joyful awe,
A draft on Netlify, shiny and new,
Preview for reviewers — a quick peek or two,
Thump-thump — the rabbit says "ready for review!"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "ci: add automation for build preview" is concise, clear, and directly related to the main change in the changeset. It accurately describes that a CI workflow for build preview automation is being added, which aligns with the file modification that introduces a new GitHub Actions workflow for Netlify preview functionality. The title is specific enough that a reviewer scanning history would understand the primary purpose of the change.
Linked Issues Check ✅ Passed The code changes directly address the objective outlined in linked issue #2064, which requests Netlify preview functionality for the Community repository. The new GitHub Actions workflow implements exactly what was requested: it automates the process of generating a preview environment for documentation changes by checking out the contributor PR, syncing docs into the website repository, building the website, deploying a draft Netlify preview, and commenting the preview URL on the PR. The implementation provides the preview environment for documentation changes in the community repo as specified in the issue.
Out of Scope Changes Check ✅ Passed All changes in this pull request are directly in scope and related to the linked issue objective. The single modified file, .github/workflows/manual-netlify-preview.yml, contains only the new GitHub Actions workflow that implements the Netlify preview automation feature requested in issue #2064. There are no extraneous modifications, unrelated updates, or changes that deviate from the stated objective of adding build preview automation for the community repository.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@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: 5

🧹 Nitpick comments (1)
.github/workflows/manual-netlify-preview.yml (1)

1-61: Add comprehensive error handling and logging.

The workflow lacks error handling and validation checks between major steps. Given the PR notes that the workflow "might not work the first time," consider adding:

  1. Error handling: Use set -e to halt on errors, and add explicit error checks.
  2. Validation: Verify prerequisites (secrets, directories, dependencies) exist before proceeding.
  3. Logging: Add diagnostic output for troubleshooting when steps fail.
  4. Timeouts: Consider adding job/step timeouts to prevent hangs.

Example improvements:

 jobs:
   preview:
     runs-on: ubuntu-latest
+    timeout-minutes: 15
 
     steps:
       - name: Checkout community PR
         uses: actions/checkout@v5
+        with:
+          fetch-depth: 0  # Full history for context
 
+      - name: Validate required secrets
+        run: |
+          for secret in NETLIFY_AUTH_TOKEN NETLIFY_SITE_ID GH_TOKEN; do
+            if [[ -z "${!secret}" ]]; then
+              echo "❌ Missing required secret: $secret"
+              exit 1
+            fi
+          done

Would you like me to generate a hardened version of this workflow with comprehensive error handling, validation, and logging?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56521b8 and 1d5d516.

📒 Files selected for processing (1)
  • .github/workflows/manual-netlify-preview.yml (1 hunks)
🔇 Additional comments (2)
.github/workflows/manual-netlify-preview.yml (2)

3-6: Trigger configuration is appropriate.

The path-based filter correctly restricts the workflow to PRs affecting the docs/ directory.


14-14: As of October 24, 2025, actions/checkout@v5 is the recommended version. The workflow is already using the current recommended version at both lines 14 and 17–21. No changes required.

Copy link

@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: 0

🧹 Nitpick comments (2)
.github/workflows/manual-netlify-preview.yml (2)

23-28: Improve defensive coding in docs sync step.

The glob patterns in the copy operation should be quoted to handle edge cases with filenames containing spaces. Additionally, while line 27 correctly removes the README (addressing earlier feedback), the rm -rf on line 25 could be hardened with a directory existence check to prevent errors on first run or in edge cases.

For maximum robustness, consider:

       - name: Sync docs into website
         run: |
-          rm -rf website/markdown/docs/community/*
-          cp -R docs/* website/markdown/docs/community/
+          if [[ -d "website/markdown/docs/community" ]]; then
+            rm -rf "website/markdown/docs/community"/*
+          fi
+          cp -R "docs"/* "website/markdown/docs/community/"
           rm website/markdown/docs/community/README.md

This guards against failures if the destination directory doesn't exist and applies defensive quoting to glob patterns.


49-50: Document required secrets configuration.

The workflow references three secrets: NETLIFY_AUTH_TOKEN, NETLIFY_SITE_ID, and GH_TOKEN. These must be configured in the repository settings before the workflow can run successfully. Without them, the workflow will fail silently or with unclear errors.

Consider adding a note in CONTRIBUTING.md or creating a workflow setup guide documenting:

  • NETLIFY_AUTH_TOKEN: Netlify personal access token with deploy permissions
  • NETLIFY_SITE_ID: Netlify site ID for the preview deployment target
  • GH_TOKEN: GitHub token with repo and pull-request scopes

Alternatively, add an early validation step to fail with a clear message if these secrets are missing.

Would you like me to generate a validation step or documentation snippet for these secrets?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d5d516 and d461751.

📒 Files selected for processing (1)
  • .github/workflows/manual-netlify-preview.yml (1 hunks)
🔇 Additional comments (2)
.github/workflows/manual-netlify-preview.yml (2)

45-61: Deploy step error handling looks solid.

The deploy step correctly:

  • Uses set -e for fail-fast behavior
  • Validates the build output directory exists before deploying
  • Provides a clear error message if the directory is missing
  • Captures the deploy JSON and extracts the URL via jq
  • Stores the URL in GITHUB_OUTPUT for downstream steps

The fix addressing the incorrect build output directory (from .netlify/build/publish to out) and error handling appears well-implemented.


42-42: No changes required.

The version 23.9.5 is the latest available version of netlify-cli on npm. The pinned version in line 42 is current, valid, and appropriate. No updates or security concerns identified.

@derberg derberg requested a review from bandantonio October 27, 2025 07:29
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.

[📑 Docs]: Netlify preview for the Community Repos

2 participants