Example Workflows
Two complete GitHub Actions workflows you can copy: one for an iOS app and one for an Android app. Each asks Helm for a PR preview backend, builds and tests the app on Helm's build machines with fastlane and the build cache, sends the build to your testers through Helm, and tears the preview down at the end.
.github/scripts/helm-ota-upload.sh from
Upload Builds from CI.
What you're about to do, in plain English
Each workflow has three jobs that run one after the other:
- preview asks Helm for a copy of your backend for this branch or pull request and waits until it answers. It only sends web requests, so it runs on GitHub's own
ubuntu-latestrunner and does not hold one of Helm's build machines while it waits. - build runs on Helm. It checks out the code, restores the build cache, runs the fastlane
testlane, runs thebuildlane with the preview's address built into the app, and sends the finished app to Helm so testers can install it. - teardown removes the preview when the run ends, whether the build passed or failed.
If your app does not need its own backend, delete the preview and
teardown jobs and the needs: preview and PREVIEW_URL lines.
iOS app
The Fastfile
Save this as fastlane/Fastfile, and change MyApp to your workspace and
scheme. The build lane signs with fastlane match, so the
MATCH_ secrets below must be set. The app reads its backend address from an
Info.plist key whose value is $(API_BASE_URL); see "Pointing a build at
a PR preview backend" in
Upload Builds from CI.
default_platform(:ios)
WORKSPACE = "MyApp.xcworkspace"
SCHEME = "MyApp"
# Folders the workflow keeps in the Helm build cache.
SPM_DIR = File.join(ENV.fetch("RUNNER_TEMP", "/tmp"), "SourcePackages")
platform :ios do
before_all do
# A temporary keychain for this job, so signing never touches the machine's own.
setup_ci if ENV["CI"]
end
lane :test do
run_tests(
workspace: WORKSPACE,
scheme: SCHEME,
cloned_source_packages_path: SPM_DIR
)
end
lane :build do
match(type: "adhoc", readonly: true)
build_app(
workspace: WORKSPACE,
scheme: SCHEME,
export_method: "ad-hoc",
cloned_source_packages_path: SPM_DIR,
output_directory: File.join(ENV.fetch("RUNNER_TEMP", "/tmp"), "export"),
xcargs: "API_BASE_URL='#{ENV.fetch('PREVIEW_URL', '')}'"
)
end
end
run_tests chooses a simulator itself. To choose one, add
devices: ["iPhone 17"] with a name from
xcrun simctl list devices available; the machines have the iOS 27.0 and 27.1
simulator runtimes.
The secrets
In GitHub, open the repository's Settings, then Secrets and variables → Actions, and add:
MATCH_GIT_URL— the HTTPS address of your certificates repository, for examplehttps://github.com/your-org/certificates.git. SSH addresses do not work on Helm.MATCH_GIT_BASIC_AUTHORIZATION— the base64 ofusername:tokenfor a GitHub token that can read that repository, with nothing else in the value. Make it withprintf '%s' 'username:token' | base64.MATCH_PASSWORD— the password that encrypts the certificates repository.
The workflow
Save this as .github/workflows/ios.yml. Change MyApp in the cache keys if you like; the names only need to be the same from run to run.
https://app.helmcode.dev/api and ask for the audience https://app.helmcode.dev. Workflows that use https://helmcode.dev for either keep working; you do not need to change them.
name: iOS
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
id-token: write # lets the jobs ask GitHub for an OIDC token for Helm
contents: read
# A newer push to the same pull request cancels the older run, because a new
# preview request for a pull request replaces its previous preview.
concurrency:
group: ios-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
HELM_API_URL: https://app.helmcode.dev/api
jobs:
preview:
runs-on: ubuntu-latest
timeout-minutes: 45
outputs:
preview_id: ${{ steps.create.outputs.preview_id }}
preview_url: ${{ steps.wait.outputs.preview_url }}
steps:
- name: Ask Helm for a preview
id: create
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
TOKEN=$(curl -s -H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://app.helmcode.dev" \
| python3 -c "import sys,json; print(json.load(sys.stdin)['value'])")
BODY=$(python3 -c "import json,os; print(json.dumps({'platform': 'ios', 'branch': os.environ['BRANCH'], 'pr_number': int(os.environ['PR_NUMBER'] or 0) or None}))")
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "${HELM_API_URL}/previews/" \
-H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" -d "${BODY}")
CODE=$(echo "$RESPONSE" | tail -1); JSON=$(echo "$RESPONSE" | sed '$d')
[ "$CODE" = "201" ] || { echo "::error::Preview request failed (HTTP $CODE): $JSON"; exit 1; }
echo "preview_id=$(echo "$JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")" >> "$GITHUB_OUTPUT"
- name: Wait until the preview is ready
id: wait
env:
PREVIEW_ID: ${{ steps.create.outputs.preview_id }}
run: |
for i in $(seq 1 120); do
TOKEN=$(curl -s -H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://app.helmcode.dev" \
| python3 -c "import sys,json; print(json.load(sys.stdin)['value'])")
JSON=$(curl -s -H "Authorization: Bearer ${TOKEN}" "${HELM_API_URL}/previews/${PREVIEW_ID}/")
STATUS=$(echo "$JSON" | python3 -c "import sys,json; print(json.load(sys.stdin).get('status') or '')")
echo "Preview status: ${STATUS}"
if [ "$STATUS" = "ready" ]; then
echo "preview_url=$(echo "$JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['base_url'])")" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "$STATUS" = "failed" ] || [ "$STATUS" = "destroyed" ]; then
echo "::error::Preview ${STATUS}: $(echo "$JSON" | python3 -c "import sys,json; print(json.load(sys.stdin).get('error_message') or '')")"
exit 1
fi
sleep 20
done
echo "::error::The preview was not ready after 40 minutes"; exit 1
build:
needs: preview
runs-on: [self-hosted, macOS, ARM64, helm-macos-26]
timeout-minutes: 60
env:
PREVIEW_URL: ${{ needs.preview.outputs.preview_url }}
HELM_ENVIRONMENT: qa
MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
# A refused git credential fails at once instead of waiting for a password.
GIT_TERMINAL_PROMPT: "0"
GIT_CONFIG_COUNT: "1"
GIT_CONFIG_KEY_0: credential.helper
GIT_CONFIG_VALUE_0: ""
steps:
- uses: actions/checkout@v4
- name: Finish setting up Xcode
run: xcodebuild -runFirstLaunch || true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
- name: Gem cache
uses: Helm-Development/Build-Cache@v1
with:
path: vendor/bundle
key: gems-${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
gems-${{ runner.os }}-
- name: Install gems
run: |
bundle config set --local path vendor/bundle
bundle install --jobs 4
- name: Swift package cache
uses: Helm-Development/Build-Cache@v1
with:
path: ${{ runner.temp }}/SourcePackages
key: spm-${{ runner.os }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
spm-${{ runner.os }}-
- name: Run the tests
run: bundle exec fastlane ios test
- name: Build the app against the preview
run: bundle exec fastlane ios build
- name: Read the app details from the .ipa
run: |
IPA_PATH=$(ls "$RUNNER_TEMP"/export/*.ipa | head -1)
echo "IPA_PATH=$IPA_PATH" >> "$GITHUB_ENV"
mkdir -p "$RUNNER_TEMP/ipa"
unzip -q -o "$IPA_PATH" 'Payload/*.app/Info.plist' -d "$RUNNER_TEMP/ipa"
PLIST=$(ls "$RUNNER_TEMP"/ipa/Payload/*.app/Info.plist | head -1)
read_key() { /usr/libexec/PlistBuddy -c "Print :$1" "$PLIST" 2>/dev/null || true; }
APP_NAME=$(read_key CFBundleDisplayName)
[ -n "$APP_NAME" ] || APP_NAME=$(read_key CFBundleName)
echo "APP_NAME=$APP_NAME" >> "$GITHUB_ENV"
echo "BUNDLE_ID=$(read_key CFBundleIdentifier)" >> "$GITHUB_ENV"
echo "VERSION=$(read_key CFBundleShortVersionString)" >> "$GITHUB_ENV"
echo "BUILD_NUMBER=$(read_key CFBundleVersion)" >> "$GITHUB_ENV"
- name: Send the build to Helm
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
RELEASE_NOTES: "Uses the preview backend ${{ needs.preview.outputs.preview_url }}"
run: .github/scripts/helm-ota-upload.sh "$IPA_PATH" ios
teardown:
needs: [preview, build]
# Run even when a job before it failed, but only when a preview was created.
if: ${{ always() && needs.preview.outputs.preview_id != '' }}
runs-on: ubuntu-latest
steps:
- name: Tear down the preview
env:
PREVIEW_ID: ${{ needs.preview.outputs.preview_id }}
run: |
TOKEN=$(curl -s -H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://app.helmcode.dev" \
| python3 -c "import sys,json; print(json.load(sys.stdin)['value'])")
RESPONSE=$(mktemp)
CODE=$(curl -s -o "$RESPONSE" -w "%{http_code}" -X POST \
"${HELM_API_URL}/previews/${PREVIEW_ID}/teardown/" -H "Authorization: Bearer ${TOKEN}")
echo "Teardown answered HTTP ${CODE}"
# A pinned preview is kept on purpose: Helm answers 409 preview_pinned.
if [ "$CODE" = "409" ] && grep -q '"preview_pinned"' "$RESPONSE"; then
echo "Preview is pinned; left running"
exit 0
fi
[ "$CODE" = "200" ]
Tearing the preview down at the end means the build you sent to testers points at a backend
that no longer exists. If testers need the backend after the run, pin the preview on the PR
Previews page: the teardown job then logs "Preview is pinned; left running" and
leaves it up. To stop tearing previews down at all, delete the teardown job; the preview is then removed when the pull request closes or its time
runs out (see Preview Lifecycle).
Android app
The Fastfile
Save this as fastlane/Fastfile. The build lane passes the preview's address to Gradle as the property apiBaseUrl.
default_platform(:android)
platform :android do
lane :test do
gradle(task: "testDebugUnitTest")
end
lane :build do
gradle(
task: "assemble",
build_type: "Debug",
properties: { "apiBaseUrl" => ENV.fetch("PREVIEW_URL", "") }
)
end
end
Read the property into BuildConfig as shown in "Pointing a build at a PR preview
backend" in
Upload Builds from CI.
Add the secret ANDROID_DEBUG_KEYSTORE_BASE64 described on that page, so each build
installs over the last one.
The workflow
Save this as .github/workflows/android.yml. If your app module is not called app, change app/build/outputs/apk/debug.
name: Android
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
id-token: write # lets the jobs ask GitHub for an OIDC token for Helm
contents: read
concurrency:
group: android-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
HELM_API_URL: https://app.helmcode.dev/api
jobs:
preview:
runs-on: ubuntu-latest
timeout-minutes: 45
outputs:
preview_id: ${{ steps.create.outputs.preview_id }}
preview_url: ${{ steps.wait.outputs.preview_url }}
steps:
- name: Ask Helm for a preview
id: create
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
TOKEN=$(curl -s -H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://app.helmcode.dev" \
| python3 -c "import sys,json; print(json.load(sys.stdin)['value'])")
BODY=$(python3 -c "import json,os; print(json.dumps({'platform': 'android', 'branch': os.environ['BRANCH'], 'pr_number': int(os.environ['PR_NUMBER'] or 0) or None}))")
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "${HELM_API_URL}/previews/" \
-H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" -d "${BODY}")
CODE=$(echo "$RESPONSE" | tail -1); JSON=$(echo "$RESPONSE" | sed '$d')
[ "$CODE" = "201" ] || { echo "::error::Preview request failed (HTTP $CODE): $JSON"; exit 1; }
echo "preview_id=$(echo "$JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")" >> "$GITHUB_OUTPUT"
- name: Wait until the preview is ready
id: wait
env:
PREVIEW_ID: ${{ steps.create.outputs.preview_id }}
run: |
for i in $(seq 1 120); do
TOKEN=$(curl -s -H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://app.helmcode.dev" \
| python3 -c "import sys,json; print(json.load(sys.stdin)['value'])")
JSON=$(curl -s -H "Authorization: Bearer ${TOKEN}" "${HELM_API_URL}/previews/${PREVIEW_ID}/")
STATUS=$(echo "$JSON" | python3 -c "import sys,json; print(json.load(sys.stdin).get('status') or '')")
echo "Preview status: ${STATUS}"
if [ "$STATUS" = "ready" ]; then
echo "preview_url=$(echo "$JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['base_url'])")" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "$STATUS" = "failed" ] || [ "$STATUS" = "destroyed" ]; then
echo "::error::Preview ${STATUS}: $(echo "$JSON" | python3 -c "import sys,json; print(json.load(sys.stdin).get('error_message') or '')")"
exit 1
fi
sleep 20
done
echo "::error::The preview was not ready after 40 minutes"; exit 1
build:
needs: preview
runs-on: [self-hosted, Linux, X64, helm-linux-android]
timeout-minutes: 60
env:
PREVIEW_URL: ${{ needs.preview.outputs.preview_url }}
HELM_ENVIRONMENT: qa
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- name: Gradle cache
uses: Helm-Development/Build-Cache@v1
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/libs.versions.toml') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Gem cache
uses: Helm-Development/Build-Cache@v1
with:
path: vendor/bundle
key: gems-${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
gems-${{ runner.os }}-
- name: Install gems
run: |
bundle config set --local path vendor/bundle
bundle install --jobs 4
- name: Install the shared debug signing key
env:
ANDROID_DEBUG_KEYSTORE_BASE64: ${{ secrets.ANDROID_DEBUG_KEYSTORE_BASE64 }}
run: |
mkdir -p "$HOME/.android"
echo -n "$ANDROID_DEBUG_KEYSTORE_BASE64" | base64 --decode > "$HOME/.android/debug.keystore"
- name: Run the tests
run: bundle exec fastlane android test
- name: Build the app against the preview
run: bundle exec fastlane android build
- name: Read the app details from the APK
run: |
APK_PATH=$(ls app/build/outputs/apk/debug/*.apk | head -1)
AAPT="$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -1)/aapt"
BADGING=$("$AAPT" dump badging "$APK_PATH")
echo "APK_PATH=$APK_PATH" >> "$GITHUB_ENV"
echo "BUNDLE_ID=$(echo "$BADGING" | sed -n "s/^package: name='\([^']*\)'.*/\1/p")" >> "$GITHUB_ENV"
echo "BUILD_NUMBER=$(echo "$BADGING" | sed -n "s/.*versionCode='\([^']*\)'.*/\1/p")" >> "$GITHUB_ENV"
echo "VERSION=$(echo "$BADGING" | sed -n "s/.*versionName='\([^']*\)'.*/\1/p")" >> "$GITHUB_ENV"
echo "APP_NAME=$(echo "$BADGING" | sed -n "s/^application-label:'\(.*\)'$/\1/p")" >> "$GITHUB_ENV"
- name: Send the build to Helm
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
RELEASE_NOTES: "Uses the preview backend ${{ needs.preview.outputs.preview_url }}"
run: .github/scripts/helm-ota-upload.sh "$APK_PATH" android
- name: Stop Gradle so its cache can be saved cleanly
if: always()
run: ./gradlew --stop || true
teardown:
needs: [preview, build]
# Run even when a job before it failed, but only when a preview was created.
if: ${{ always() && needs.preview.outputs.preview_id != '' }}
runs-on: ubuntu-latest
steps:
- name: Tear down the preview
env:
PREVIEW_ID: ${{ needs.preview.outputs.preview_id }}
run: |
TOKEN=$(curl -s -H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://app.helmcode.dev" \
| python3 -c "import sys,json; print(json.load(sys.stdin)['value'])")
RESPONSE=$(mktemp)
CODE=$(curl -s -o "$RESPONSE" -w "%{http_code}" -X POST \
"${HELM_API_URL}/previews/${PREVIEW_ID}/teardown/" -H "Authorization: Bearer ${TOKEN}")
echo "Teardown answered HTTP ${CODE}"
# A pinned preview is kept on purpose: Helm answers 409 preview_pinned.
if [ "$CODE" = "409" ] && grep -q '"preview_pinned"' "$RESPONSE"; then
echo "Preview is pinned; left running"
exit 0
fi
[ "$CODE" = "200" ]
The preview and teardown jobs are the same as in the iOS workflow,
apart from 'platform': 'android'.
The Android machines have the emulator with hardware acceleration, so you can also run
instrumented tests in the job, for example with
gradle(task: "connectedDebugAndroidTest") in a lane after starting an emulator.
Troubleshooting
The build job never starts
GitHub shows "Waiting for a runner to pick up this job" when no Helm runner matches the job. Check
that runs-on names a Helm label exactly (helm-macos-26 or
helm-linux-android), that any other labels on the line match it, and that
Company settings → GitHub shows the repository's account as
connected. Every check is in the Troubleshooting section of
Run Builds on Helm.
A job on GitHub's own labels (ubuntu-latest, macos-*) runs on GitHub,
never on Helm.
The preview job waits at "queued" or "provisioning"
Queued means the preview is waiting for room on Helm's preview machines. Provisioning means Helm is copying your branch, building the image and starting the app; a small app is typically ready in about two minutes, and a first build of a large image takes longer. What you can do:
- Open the project's PR Previews page. The row updates by itself and shows a red reason if the preview failed.
- If it has been Queued for more than 15 minutes, tear it down from the row's Actions menu and run the workflow again.
- If it is Provisioning for more than 45 minutes, something is wrong: Helm gives up on each step well before that and marks the preview Failed. Tear it down and run the workflow again.
- If it happens again, contact Helm support with the preview's address or the link to the run.
Helm support then checks that Helm's preview machines are online and have room, that nothing on Helm's side is holding the request back, and what the preview's own logs say.
The preview job fails with a reason
The reason, such as build_failed or readiness_failed, comes from your
backend repository or its settings. The fixes are in the Troubleshooting section of
Set Up PR Previews.
The cache steps never restore anything
The first run of a key has nothing to restore, and a pull request restores only from its own
branch and the default branch. Run the workflow once on main. The other reasons are
in the Troubleshooting section of
Caching.
match cannot clone the certificates repository, or hangs
Use the HTTPS address in MATCH_GIT_URL, check that
MATCH_GIT_BASIC_AUTHORIZATION is plain base64 of username:token, and
keep the four GIT_ variables in the job so a refused credential fails at once.
The upload to Helm fails
See the Troubleshooting section of Upload Builds from CI, which lists every answer the build API gives.