Skip to main content

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

  1. Developer pushes code to main
  2. CI runs swiftpatch deploy
  3. 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

VariableDescription
SWIFTPATCH_CI_TOKENCI token for authentication
warning

Always use CI secrets management. Never hardcode tokens in your workflow files.

Best Practices

  1. Always use --hermes if Hermes is enabled (RN 0.70+ default)
  2. Match --app-version exactly to the native binary version
  3. Run tests before deploying -- broken code should never reach swiftpatch deploy
  4. Ensure clean working directory -- deploy bundles whatever is in the working directory
  5. Use staged rollouts -- manage rollout percentage from the dashboard
  6. Include commit info in release descriptions for traceability
  7. Separate staging and production tokens
  8. Monitor after deploy -- watch for rollback events in the dashboard
  9. Sign bundles with --private-key for enterprise security