AppForShare

A test build link on every pull request, for iOS and Android

· 6 min read

A test build link on every pull request, for iOS and Android

Short answer: To get a test build link on every pull request, build the iOS or Android app in the pull request workflow, upload the file to a distribution service, and post the install link and QR code as a comment on the pull request. With the AppForShare GitHub Action, pr-comment: true writes that comment and pr-channel: true gives each pull request its own channel, pr-<number>, with one stable link that every new push updates and that is deleted when the pull request closes.

Web teams have had preview deployments for years: open a pull request, get a URL, click it. Mobile teams usually review a screenshot or a video, or wait for the change to reach the shared beta build. That makes design reviews slow and lets bugs reach the main branch, because the person who should test the change never had it on a phone. This guide shows how to wire a preview build per pull request with GitHub Actions, what to watch out for on iOS, and how to keep the number of links under control.

What a good preview flow does

  • A link in the pull request. Reviewers should not hunt for a build in a separate tool. The link and a QR code sit in the pull request itself.
  • One link per pull request, not per push. A pull request gets many pushes. If every push posts a new link, reviewers install an old one. A stable link that always opens the newest build of that pull request avoids it.
  • Clean up on close. Merged or closed pull requests should not leave installable builds behind for months.
  • A quick health check. A failing store rule, such as a missing usage description or a debug flag, is cheaper to catch in review than at submission time.

The workflow

Run the workflow on opened, synchronize, reopened and closed. The job needs pull-requests: write to post the comment and deployments: write for the GitHub Deployment. Skip the build steps when the pull request closes; the upload step then only removes the channel.

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]

jobs:
  android:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
      deployments: write
    steps:
      - uses: actions/checkout@v4
        if: github.event.action != 'closed'
      - name: Build
        if: github.event.action != 'closed'
        run: ./gradlew assembleRelease
      - uses: appforshare/appforshare-action@v1
        with:
          file: app/build/outputs/apk/release/app-release.apk
          token: ${{ secrets.APPFORSHARE_TOKEN }}
          pr-comment: true
          pr-channel: true

Store an API token as the repository secret APPFORSHARE_TOKEN; an upload only token is enough. Uploads with a token are on Pro and Team.

What reviewers get

  • One comment, updated on each run. It shows the install links and QR codes, the store readiness result and the channel link. When an iOS job and an Android job run for the same pull request and their projects are paired, both builds share the comment and the channel.
  • A channel named after the pull request. The build goes into pr-<number>, created on first use. Its page shows "PR #N" and the pull request title, synced on every upload. The channel link stays the same for the life of the pull request and always opens the newest build in it.
  • A GitHub Deployment. The pull request shows a deployment in the appforshare environment that points at the channel, next to the checks. If the job lacks the permission, the Action prints a warning and carries on.
  • Clean up. On closed, the Action deletes the channel, uploads nothing and marks the pull request's deployments inactive. The builds themselves stay and follow your normal expiry and automatic clean up. The comment stays on the pull request.

Pull request channels do not count toward the regular channels of an app. Pro keeps up to 50 of them per workspace and Team up to 200; at the cap, the pull request channel with the oldest build is deleted first, so a forgotten closed run never blocks new pull requests.

Gate the merge on store readiness

Every upload with an account gets a store readiness check: ready, review or blocked, with the reason and fix for each line. Add fail-on: blocked to fail the step when a build would be refused by the store, or fail-on: review to be stricter. The build is still uploaded, so reviewers can install it while the author fixes the problem. To check before anything is sent, check: true runs the same rules on the runner and fails the step first. The check is guidance for store review, not a promise of approval.

iOS needs one extra thought

An Android APK installs on any phone that allows it. An iOS build from a pull request installs on an iPhone only if that iPhone is in the build's provisioning profile. For preview builds that means an ad hoc or development profile that lists your reviewers' devices. Add a reviewer's device once, rebuild the profile, and every later pull request build installs for them. The steps are in iOS ad hoc device registration, and the signing setup for GitHub runners is in building iOS on GitHub Actions.

Forks, secrets and cost

  • Pull requests from forks. GitHub gives them a read only token and no secrets, so nothing is uploaded from a fork. That is the safe default; do not work around it with pull_request_target for a job that builds untrusted code.
  • Runner minutes. A mobile build on every push can use a lot of CI time. Cache Gradle and CocoaPods, and consider building only when app code changed, with a paths filter on the trigger.
  • Who can install. A preview link is still a link. Use a password or a private project if the work is confidential.

Other CI services and the CLI

The same works from any step with the CLI:

npx appforshare upload app-release.apk --pr-channel --pr-comment
npx appforshare channel list --app com.acme.shop
npx appforshare channel delete --pr 128 --yes

--pr-channel reads the pull request from the GitHub Actions event, and on Codemagic from CM_PULL_REQUEST_NUMBER for GitHub repositories. On GitLab, Bitbucket or other CI, use --channel with the branch name to keep one channel per branch instead, and delete it when the branch is merged. The CI setup for each service is in upload from CI, and every option of the pull request flow is in pull request channels.

Common questions

Can a reviewer install the change without a computer?

Yes. They open the pull request on the phone, tap the channel link and install from the browser. On a computer, the comment's QR code opens the same page on the phone.

Does every push post a new comment?

No. The Action keeps one comment per pull request and updates it on each run.

What happens to the builds after the merge?

The pull request channel is deleted when the workflow runs on closed. The builds remain under the app until they expire or you delete them.

Does it work for Flutter and React Native?

Yes. The Action uploads the .apk, .aab or .ipa your build step produces, whatever framework made it.

Keep reading

App Distribution Platform · · 5 min read

AppForShare File Size and Upload Limits

AppForShare limits the size of each build you upload by plan: 50 MB without an account, 150 MB on the Free plan, 2 GB on Pro and 4 GB on Team. Accounts also have a storage total, and every plan...