CI/CD Integration
Automate your OTA deployments so every push to main ships an update to your users -- no manual steps required.
tip
For CLI reference, see CI/CD CLI Reference. This guide focuses on step-by-step setup.
How It Works
- Developer pushes code to
main - CI runs
swiftpatch deploy - Users receive the update on next app launch
Prerequisites
Before you start
- SwiftPatch CLI installed in your CI environment
- A CI token stored as a secret (
SWIFTPATCH_CI_TOKEN)
Step 1: Create a CI Token
Step 1: Go to your app in the dashboard.
Step 2: Navigate to Settings > API Keys.
Step 3: Click Create Token and name it.
Step 4: Copy immediately -- it is shown only once.
note
CI tokens use prefix sp_ci_ and are scoped to one app.
Step 2: Set Up GitHub Actions
.github/workflows/ota-deploy.yml
name: OTA Deploy
on:
push:
branches: [main]
paths:
- 'src/**'
- 'package.json'
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [ios, android]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm install -g @swiftpatch/cli
- name: Deploy
run: |
swiftpatch deploy \
-p ${{ matrix.platform }} \
--hermes \
-n "Deploy from commit ${{ github.sha }}" \
--ci-token ${{ secrets.SWIFTPATCH_CI_TOKEN }}
Step 3: Separate Staging and Production
Use different branches and tokens for each environment:
jobs:
staging:
if: github.ref == 'refs/heads/develop'
steps:
- # ... setup
- run: swiftpatch deploy -p ios --hermes --ci-token ${{ secrets.SWIFTPATCH_STAGING_CI_TOKEN }}
production:
if: github.ref == 'refs/heads/main'
steps:
- # ... setup
- run: swiftpatch deploy -p ios --hermes --ci-token ${{ secrets.SWIFTPATCH_CI_TOKEN }}
Environment Variables
| Variable | Description |
|---|---|
SWIFTPATCH_CI_TOKEN | CI token for authentication |
warning
Always use CI secrets management. Never hardcode tokens in your workflow files.
Best Practices
- Always use
--hermesif Hermes is enabled (RN 0.70+ default) - Match
--app-versionexactly to the native binary version - Run tests before deploying -- broken code should never reach
swiftpatch deploy - Ensure clean working directory --
deploybundles whatever is in the working directory - Use staged rollouts -- manage rollout percentage from the dashboard
- Include commit info in release descriptions for traceability
- Separate staging and production tokens
- Monitor after deploy -- watch for rollback events in the dashboard
- Sign bundles with
--private-keyfor enterprise security