Add Android app previews to GitHub pull requests
A screenshot shows what changed on one screen. An Android pull request preview lets a reviewer open the build in a browser and tap through the whole flow. With Limrun's Android preview action, GitHub Actions starts a remote Gradle build, uploads the APK, and adds a preview link to the pull request.
Add the preview workflow
In your GitHub repository, add a Limrun API key as the Actions secret LIM_API_KEY. Use an API key from the Limrun organization your reviewers belong to. This example assumes your Gradle project has a wrapper at the repository root and assembleDebug produces an installable APK.
Save the workflow as .github/workflows/android-preview.yml.
name: Android preview
on:
pull_request:
types: [opened, synchronize, reopened, closed]
permissions:
contents: read
pull-requests: write
concurrency:
group: android-preview-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
preview:
if: >-
github.event.pull_request.head.repo.full_name == github.repository
&& github.event.pull_request.user.login != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: github.event.action != 'closed'
- uses: limrun-inc/android-preview-action@v0.2.0
with:
api-key: ${{ secrets.LIM_API_KEY }}
tasks: assembleDebug
Use this workflow for trusted branches in your repository. The job skips pull requests from forks and Dependabot because those runs normally lack the Actions secret. Keep the closed event so the action can clean up remaining builders and update the preview comment after the pull request closes.
If your project has flavors, set tasks to the variant reviewers should try, such as :app:assembleDemoDebug. In a monorepo, set project-path to the directory to sync and gradle-project-path to the Gradle root relative to that directory. Include any shared modules the build reads. Android preview action inputs
Open the build from the pull request
Push a branch and open a pull request. When the build succeeds, follow the preview link in the action's comment. Sign in to the Limrun organization that owns the APK, then select Start device in Playground. The emulator starts, installs the build, and launches the app. Select the Stop (×) button when you finish reviewing.
The action uses one APK asset per pull request. A later successful build replaces that asset and updates the same comment. To verify a new push, wait for its workflow to finish and open the preview on a fresh device.
Open the screen the pull request changes
If your app handles deep links, pass open-url to take reviewers directly to the changed screen. Add this line under with in the preview step, using a route your app handles:
open-url: 'myapp://checkout?source=preview'
The action encodes the URL and opens it after the app launches. Use a route without credentials or private test data because the URL appears in the pull request comment and browser history. Put a short test instruction in the pull request description if the route requires an account or an earlier step.
For background on what the device can do, see the cloud Android emulator setup guide. If a reviewer finds a bug that needs a breakpoint, connect Android Studio to the running emulator.