This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Create preview builds for pull requests with EAS Workflows

Edit page

Learn how to create preview build workflows for Slack notifications and PR previews using EAS Workflows.


Sharing in-progress mobile changes with teammates and pull request (PR) reviewers often requires them to check out a branch and run a development server locally.

Learning outcomes

  • Automate preview builds with fingerprinting for internal distribution
  • Post Slack notifications when a build finishes
  • Publish an OTA update on every pull request and comment on the PR with a link to test it

Prerequisites

3 requirements

1.

expo-updates installed

Install the expo-updates library:

Terminal
npx expo install expo-updates

2.

EAS Update configured

To configure EAS Update, run:

Terminal
eas update:configure

The above command adds the update URL and runtime version to app.json, and adds a channel field to each build profile in eas.json.

3.

Preview build created

To receive PR preview updates, reviewers need a preview build with expo-updates and the EAS Update channel installed on their device. To create one:

Terminal
eas build --profile preview --platform all

Since expo-updates is a native library, this build embeds both its native code and the channel from eas.json. Running the above command also allows EAS CLI to generate credentials the first time we trigger a preview build.

The build job type for preview builds

Teams use preview builds for stakeholder testing. Members install the build through internal distribution onto their device/emulator/simulator. They do not have to run a development server or check out the branch to test changes.

Like development builds, we add fingerprints to avoid unnecessary rebuilds when native code doesn't change.

1

Add a preview.yml

Inside .eas/workflows/, let's add a new file called preview.yml. This workflow file uses the preview profile.

.eas/workflows/preview.yml
name: Preview builds jobs: fingerprint: name: Fingerprint type: fingerprint environment: preview get_android_build: name: Check for existing Android build needs: [fingerprint] type: get-build params: fingerprint_hash: ${{ needs.fingerprint.outputs.android_fingerprint_hash }} profile: preview get_ios_build: name: Check for existing iOS build needs: [fingerprint] type: get-build params: fingerprint_hash: ${{ needs.fingerprint.outputs.ios_fingerprint_hash }} profile: preview build_android: name: Build Android needs: [get_android_build] if: ${{ !needs.get_android_build.outputs.build_id }} type: build params: platform: android profile: preview build_ios: name: Build iOS needs: [get_ios_build] if: ${{ !needs.get_ios_build.outputs.build_id }} type: build params: platform: ios profile: preview

2

Run the workflow

Run the workflow manually using the following command:

Terminal
eas workflow:run .eas/workflows/preview.yml

In the EAS dashboard, notice that the workflow follows the same fingerprint pattern we implemented for development builds. Since we are creating the preview build for the first time, it runs the build jobs for Android and iOS. If we push another commit to the main branch without changing native code, the workflow skips the build jobs since compatible builds already exist.

Slack notifications

This section is optional. Not using Slack? Skip to the next section about PR previews.

Many teams use Slack for build notifications so their team sees build status without checking the EAS dashboard. When a build completes (or skips), the slack pre-packaged job posts the status to a channel.

1

Create a Slack webhook URL

To send messages from EAS Workflows to our Slack channel, we need a webhook URL from Slack's settings:

  1. Go to api.slack.com/apps and create a new Slack app (or use an existing one).
  2. Under Features, select Incoming Webhooks and toggle it on.
  3. Click Add New Webhook and select the channel to publish notifications.
  4. Copy the webhook URL. It looks like: https://hooks.slack.com/services/TD000/B000/XXXXXXXXXX
  5. Add the webhook URL as an EAS environment variable named SLACK_WEBHOOK_URL. Open our project's Environment variables page on the EAS dashboard, create the variable for the preview environment, and set its visibility to secret since only EAS servers need to read it. Alternatively, create it with EAS CLI:
Terminal
eas env:create --name SLACK_WEBHOOK_URL --value https://hooks.slack.com/services/TD000/B000/XXXXXXXXXX --environment preview --visibility secret

2

Add a Slack notification job

Let's update preview.yml to add a notify job after the build jobs. The notify job uses webhook_url and message parameters, or a payload parameter for rich formatting with Slack Block Kit. The job reads the webhook URL from the SLACK_WEBHOOK_URL environment variable we created earlier through its environment field. Jobs default to the production environment, so setting environment: preview here is what makes the variable available.

.eas/workflows/preview.yml
name: Preview builds jobs: fingerprint: # ... get_android_build: # ... get_ios_build: # ... build_android: # ... build_ios: # ... notify: name: Notify on Slack after: [build_android, build_ios] type: slack environment: preview params: webhook_url: ${{ env.SLACK_WEBHOOK_URL }} message: 'Preview builds are ready - Android: ${{ after.build_android.status }}, iOS: ${{ after.build_ios.status }}'

The after field ensures the notification fires once the builds finish, regardless of the outcome. The message uses ${{ after.build_android.status }} and ${{ after.build_ios.status }} to include each platform's outcome (success, failure, or skipped). The team sees what happened without leaving Slack.

3

Run the workflow

Run the workflow manually using the following command:

Terminal
eas workflow:run .eas/workflows/preview.yml

On the EAS dashboard, we can verify that the Notify on Slack job runs successfully.

We can also verify this in the Slack channel integrated with the app.

PR previews using EAS Update

A PR reviewer can read the diff, but cannot see the changes visually or test them on a device.

Web teams solve this with deploy previews. When someone opens a pull request, a CI/CD workflow generates a preview link. Reviewers open the link and test the changes without checking out the branch.

For mobile, we can set up the equivalent using EAS Update. It delivers a JavaScript bundle to devices that already have a compatible build installed, skipping the native compilation step. For PR previews, an update is the right fit because reviewers can open and test quickly, then leave feedback on the PR.

EAS Workflows provides a github-comment pre-packaged job for this. It posts a comment on the pull request after the update publishes, giving reviewers a link or QR code to open the update on their device.

1

Create a pr-preview.yml

Inside .eas/workflows/, let's add a new file called pr-preview.yml. This workflow runs when a pull request is created using the on.pull_request trigger. It only publishes an update using the update job type and then posts a comment on the PR with the link to the update.

.eas/workflows/pr-preview.yml
name: PR Preview on: pull_request: branches: ['*'] jobs: publish_preview: name: Publish PR preview update type: update environment: preview params: channel: preview comment: needs: [publish_preview] type: github-comment
Before testing the above workflow, commit pr-preview.yml and push it to the main branch of our GitHub repository. EAS Workflows reads workflow files from the default branch.

2

Test with a pull request

Let's test the workflow by creating a pull request in our GitHub repository. A pull request requires a separate branch from main. Run the following command to create and switch to a new branch:

Terminal
git checkout -b test-preview

Now, let's make a visible change in the Expo project (for example, change a text string or background color). Then, commit and push the branch:

Terminal
git add .
git commit -m "Test PR preview"
git push origin test-preview

Open a pull request from test-preview to main on GitHub. The workflow runs automatically after we have created a pull request. On the EAS dashboard, we can verify that the publish_preview job runs first and the comment job runs after it succeeds.

On the GitHub pull request, a comment should appear with a link or QR code to test the update on a device.

Using the link or QR code in the comment, we can now open the update on our device or emulator/simulator and test the changes.

Summary

Chapter 3: Preview builds

We created a preview build workflow with fingerprinting, added Slack notifications for build status, and set up PR previews using EAS Update so reviewers can test changes without checking out a branch.

In the next chapter, learn how to run end-to-end tests with Maestro in an EAS Workflows job.

Next: Chapter 4: E2E tests