-
-
Notifications
You must be signed in to change notification settings - Fork 24
Add blog: Turn Every PR Into an Installable Preview #443
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
Conversation
Covers how to set up PR previews with Capgo using GitHub Actions, enabling QA, PMs, and developers to test features without TestFlight. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ 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. Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughA new blog post article is introduced documenting PR previews functionality, covering setup procedures, implementation methods via GitHub Actions, channel switching techniques, and best practices for automated testing workflows. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 4
🤖 Fix all issues with AI agents
In `@src/content/blog/en/turn-every-pr-into-installable-preview.md`:
- Line 78: The workflow's channel creation command (bunx `@capgo/cli` channel add
pr-${{ github.event.pull_request.number }} --self-assign) can fail (e.g.,
channel already exists) but the example always proceeds to post the comment;
update the "channel add" step to detect success/failure and expose a step output
(or use a non-failing flag if the CLI supports it) and then make the
comment/post step conditional (only run when the create-channel step succeeded).
Specifically, modify the step that runs "bunx `@capgo/cli` channel add pr-${{
github.event.pull_request.number }} --self-assign" to return a clear success
indicator (exit code check, set-output or step outcome) and reference that
indicator in the comment step's if: condition so comments are only posted when
channel creation actually succeeded.
- Line 49: The internal link "/solutions/pr-preview/" is invalid and should be
fixed; locate the markdown in
src/content/blog/en/turn-every-pr-into-installable-preview.md that contains the
"/solutions/pr-preview/" URL and either update it to the correct existing path
(e.g., replace with a valid docs or blog URL) or remove the anchor entirely if
the page doesn't exist, ensuring the other links remain unchanged.
- Line 10: The frontmatter key head_image in
src/content/blog/en/turn-every-pr-into-installable-preview.md references the
image file capgo_pr_preview.webp which is missing; add the image file named
capgo_pr_preview.webp to the project's public/static assets so it is served at
/capgo_pr_preview.webp, commit the file, and if you choose a different name or
location update the head_image value to match.
- Around line 55-99: The workflow currently triggers on both pull_request opened
and synchronize and the "Comment on PR" step uses
github.rest.issues.createComment, causing duplicate comments on each push;
either restrict the trigger to only opened (change on.pull_request.types to
[opened]) or modify the "Comment on PR" step to find/update the existing bot
comment instead of always calling github.rest.issues.createComment (use
github.rest.issues.listComments + github.rest.issues.updateComment or use an
action like peter-evans/create-or-update-comment) — update the YAML's
on.pull_request.types and/or replace the createComment call in the "Comment on
PR" step so it searches for an existing comment by the bot and updates it when
present.
| author_url: 'https://x.com/martindonadieu' | ||
| created_at: 2025-01-22T00:00:00.000Z | ||
| updated_at: 2025-01-22T00:00:00.000Z | ||
| head_image: /capgo_pr_preview.webp |
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.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if the head_image file exists
fd -t f "capgo_pr_preview.webp"Repository: Cap-go/website
Length of output: 40
🏁 Script executed:
#!/bin/bash
# Find all webp files
echo "=== All webp files in repository ==="
fd -t f -e "webp"
# Check common static/public directories
echo ""
echo "=== Checking common static asset directories ==="
for dir in public static assets images img src/assets src/public; do
if [ -d "$dir" ]; then
echo "Found directory: $dir"
ls -la "$dir" 2>/dev/null | head -20
fi
doneRepository: Cap-go/website
Length of output: 22122
🏁 Script executed:
#!/bin/bash
# Check the blog post frontmatter
head -20 src/content/blog/en/turn-every-pr-into-installable-preview.mdRepository: Cap-go/website
Length of output: 1068
Add the missing head_image file /capgo_pr_preview.webp.
The blog post frontmatter references /capgo_pr_preview.webp on line 10, but this image file does not exist in the repository. Add the image to the public/ directory to ensure proper rendering of the blog post.
🤖 Prompt for AI Agents
In `@src/content/blog/en/turn-every-pr-into-installable-preview.md` at line 10,
The frontmatter key head_image in
src/content/blog/en/turn-every-pr-into-installable-preview.md references the
image file capgo_pr_preview.webp which is missing; add the image file named
capgo_pr_preview.webp to the project's public/static assets so it is served at
/capgo_pr_preview.webp, commit the file, and if you choose a different name or
location update the head_image value to match.
|
|
||
| ## Setting Up PR Previews | ||
|
|
||
| Before you can implement PR previews, your project needs to be configured with Capgo Live Updates. Follow the [Capgo quickstart guide](/docs/getting-started/quickstart/) if you haven't already. |
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.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if internal link targets exist in the content directory structure
echo "=== Checking for quickstart documentation ==="
find src/content -type f -name "*quickstart*" 2>/dev/null
echo -e "\n=== Checking for 'how-capgo-channel-switching-works' blog post ==="
find src/content -type f -name "*channel-switching*" 2>/dev/null
echo -e "\n=== Checking for 'channels' documentation ==="
find src/content/docs -type f -name "*channels*" 2>/dev/null
echo -e "\n=== Checking for 'commands' documentation ==="
find src/content/docs -type f -name "*commands*" 2>/dev/null
echo -e "\n=== Checking for 'pr-preview' solution page ==="
find src/content -type f -name "*pr-preview*" 2>/dev/null
echo -e "\n=== Directory structure check ==="
echo "docs/ structure:"
ls -la src/content/docs/en/ 2>/dev/null | head -20
echo -e "\nblog/ structure:"
ls -la src/content/blog/en/ 2>/dev/null | head -20
echo -e "\nsolutions/ structure:"
ls -la src/content/solutions/ 2>/dev/null || echo "solutions directory not found"Repository: Cap-go/website
Length of output: 4998
Fix invalid internal link at line 246.
The link /solutions/pr-preview/ (line 246) does not exist. The solutions directory is not present in the codebase. Verify the correct path or remove this link if the page does not exist. The other links (/docs/getting-started/quickstart/, /blog/how-capgo-channel-switching-works/, /docs/live-updates/channels/, /docs/cli/commands/) are valid.
🤖 Prompt for AI Agents
In `@src/content/blog/en/turn-every-pr-into-installable-preview.md` at line 49,
The internal link "/solutions/pr-preview/" is invalid and should be fixed;
locate the markdown in
src/content/blog/en/turn-every-pr-into-installable-preview.md that contains the
"/solutions/pr-preview/" URL and either update it to the correct existing path
(e.g., replace with a valid docs or blog URL) or remove the anchor entirely if
the page doesn't exist, ensuring the other links remain unchanged.
| ```yaml | ||
| name: PR Preview | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
|
|
||
| - name: Install Dependencies | ||
| run: bun install | ||
|
|
||
| - name: Build | ||
| run: bun run build | ||
|
|
||
| # Create a channel named after your PR | ||
| - name: Create PR Channel | ||
| run: bunx @capgo/cli channel add pr-${{ github.event.pull_request.number }} --self-assign | ||
| env: | ||
| CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }} | ||
|
|
||
| # Upload the build to that channel | ||
| - name: Upload to Capgo | ||
| run: bunx @capgo/cli bundle upload --channel pr-${{ github.event.pull_request.number }} | ||
| env: | ||
| CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }} | ||
|
|
||
| # Post a comment with testing instructions | ||
| - name: Comment on PR | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: ${{ github.event.pull_request.number }}, | ||
| body: '📱 **Test this PR on device:**\n\nOpen your app and switch to channel: `pr-${{ github.event.pull_request.number }}`\n\nUse the shake menu or call `setChannel()` from your app.' | ||
| }) | ||
| ``` |
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.
Workflow may post duplicate comments on each commit.
The workflow triggers on both opened and synchronize events (line 58-59). Every time new commits are pushed to the PR, the comment step (lines 89-98) will post another comment with the same testing instructions, potentially cluttering the PR.
💡 Suggested improvements
Option 1: Only comment on PR open
on:
pull_request:
- types: [opened, synchronize]
+ types: [opened, synchronize]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# ... other steps ...
# Post a comment with testing instructions
- name: Comment on PR
+ if: github.event.action == 'opened'
uses: actions/github-script@v7Option 2: Update the existing comment instead of creating a new one
You can find and update the previous bot comment instead of creating duplicates. This requires storing the comment ID or searching for it.
🤖 Prompt for AI Agents
In `@src/content/blog/en/turn-every-pr-into-installable-preview.md` around lines
55 - 99, The workflow currently triggers on both pull_request opened and
synchronize and the "Comment on PR" step uses github.rest.issues.createComment,
causing duplicate comments on each push; either restrict the trigger to only
opened (change on.pull_request.types to [opened]) or modify the "Comment on PR"
step to find/update the existing bot comment instead of always calling
github.rest.issues.createComment (use github.rest.issues.listComments +
github.rest.issues.updateComment or use an action like
peter-evans/create-or-update-comment) — update the YAML's on.pull_request.types
and/or replace the createComment call in the "Comment on PR" step so it searches
for an existing comment by the bot and updates it when present.
|
|
||
| # Create a channel named after your PR | ||
| - name: Create PR Channel | ||
| run: bunx @capgo/cli channel add pr-${{ github.event.pull_request.number }} --self-assign |
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.
Inconsistency: Best practice not implemented in the example workflow.
Line 217 advises to "Handle failures gracefully: Check that channel creation succeeds before posting comments," but the example workflow (line 78) doesn't implement this check. If channel creation fails (e.g., channel already exists from a previous run), the workflow will still post a comment with instructions for a non-existent or broken channel.
🔧 Suggested fix
Add error handling to the channel creation step:
# Create a channel named after your PR
- name: Create PR Channel
+ continue-on-error: true
+ id: create_channel
run: bunx `@capgo/cli` channel add pr-${{ github.event.pull_request.number }} --self-assign
env:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
# Upload the build to that channel
- name: Upload to Capgo
+ if: steps.create_channel.outcome == 'success'
run: bunx `@capgo/cli` bundle upload --channel pr-${{ github.event.pull_request.number }}
env:
CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }}
# Post a comment with testing instructions
- name: Comment on PR
+ if: steps.create_channel.outcome == 'success'
uses: actions/github-script@v7Alternatively, use channel add with a flag that doesn't fail if the channel exists (if such a flag is available in the CLI).
Also applies to: 217-217
🤖 Prompt for AI Agents
In `@src/content/blog/en/turn-every-pr-into-installable-preview.md` at line 78,
The workflow's channel creation command (bunx `@capgo/cli` channel add pr-${{
github.event.pull_request.number }} --self-assign) can fail (e.g., channel
already exists) but the example always proceeds to post the comment; update the
"channel add" step to detect success/failure and expose a step output (or use a
non-failing flag if the CLI supports it) and then make the comment/post step
conditional (only run when the create-channel step succeeded). Specifically,
modify the step that runs "bunx `@capgo/cli` channel add pr-${{
github.event.pull_request.number }} --self-assign" to return a clear success
indicator (exit code check, set-output or step outcome) and reference that
indicator in the comment step's if: condition so comments are only posted when
channel creation actually succeeded.
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.
Pull request overview
This pull request adds a comprehensive tutorial blog post explaining how to set up PR previews using Capgo's channel system. The article guides developers through automating the deployment of per-PR update channels using GitHub Actions, enabling QA teams, product managers, and stakeholders to test features on real devices without TestFlight delays.
Changes:
- Added comprehensive tutorial blog post on PR preview implementation
- Provided GitHub Actions workflows for automated PR preview deployment and cleanup
- Documented channel switching methods for testers (shake menu and programmatic API)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| author_url: 'https://x.com/martindonadieu' | ||
| created_at: 2025-01-22T00:00:00.000Z | ||
| updated_at: 2025-01-22T00:00:00.000Z | ||
| head_image: /capgo_pr_preview.webp |
Copilot
AI
Jan 22, 2026
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.
The referenced head_image file 'capgo_pr_preview.webp' does not exist in the public directory. This will result in a broken image link when the blog post is published. Please add the image file to the public directory or update the head_image reference to point to an existing image.
| head_image: /capgo_pr_preview.webp | |
| head_image: '' |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|



Summary
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.