-
-
Notifications
You must be signed in to change notification settings - Fork 156
ci: add automation for build preview #2109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughA new GitHub Actions workflow is added that triggers on pull requests affecting docs, checks out the contributor PR and the Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Potential attention points:
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this 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:
- Error handling: Use
set -eto halt on errors, and add explicit error checks.- Validation: Verify prerequisites (secrets, directories, dependencies) exist before proceeding.
- Logging: Add diagnostic output for troubleshooting when steps fail.
- 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 + doneWould 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
📒 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@v5is the recommended version. The workflow is already using the current recommended version at both lines 14 and 17–21. No changes required.
There was a problem hiding this 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 -rfon 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.mdThis 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, andGH_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.mdor creating a workflow setup guide documenting:
NETLIFY_AUTH_TOKEN: Netlify personal access token with deploy permissionsNETLIFY_SITE_ID: Netlify site ID for the preview deployment targetGH_TOKEN: GitHub token withrepoandpull-requestscopesAlternatively, 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
📒 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 -efor 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_OUTPUTfor downstream stepsThe fix addressing the incorrect build output directory (from
.netlify/build/publishtoout) 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.
Resolves #2064
this might not work the first time, no way for me to test it elsewhere
Summary by CodeRabbit