CI/CD

Integrating OTA Updates in Your CI/CD Pipeline

Automate React Native OTA deployments with GitHub Actions, CircleCI, and other CI/CD platforms. Complete integration guide with code examples.

S
SwiftPatch Team
DevOps
10 min read

Introduction

Manual deployments are error-prone and slow. This guide shows you how to integrate SwiftPatch into your CI/CD pipeline for fully automated OTA updates.

GitHub Actions

Basic Workflow

# .github/workflows/deploy.yml
name: Deploy OTA Update

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Build bundle
        run: npm run build

      - name: Deploy to SwiftPatch
        run: npx swiftpatch release --platform all
        env:
          SWIFTPATCH_ACCESS_KEY: ${{ secrets.SWIFTPATCH_ACCESS_KEY }}

With Staged Rollout

# .github/workflows/staged-deploy.yml
name: Staged Deployment

on:
  push:
    branches: [main]

jobs:
  deploy-staging:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'

      - run: npm ci
      - run: npm run build

      # Deploy to 10% of users first
      - name: Deploy (10% rollout)
        run: npx swiftpatch release --platform all --rollout 10
        env:
          SWIFTPATCH_ACCESS_KEY: ${{ secrets.SWIFTPATCH_ACCESS_KEY }}

  deploy-full:
    needs: deploy-staging
    runs-on: ubuntu-latest
    # Wait for monitoring period
    environment:
      name: production
      url: https://dashboard.swiftpatch.io
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'

      - run: npm ci
      - run: npm run build

      # Deploy to 100% of users
      - name: Deploy (100% rollout)
        run: npx swiftpatch release --platform all --rollout 100
        env:
          SWIFTPATCH_ACCESS_KEY: ${{ secrets.SWIFTPATCH_ACCESS_KEY }}

With Bundle Signing

# .github/workflows/signed-deploy.yml
name: Signed Deployment

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'

      - run: npm ci
      - run: npm run build

      - name: Deploy with signature
        run: |
          echo "${{ secrets.SWIFTPATCH_PRIVATE_KEY }}" > private.key
          npx swiftpatch release \
            --platform all \
            --sign \
            --private-key private.key
          rm private.key
        env:
          SWIFTPATCH_ACCESS_KEY: ${{ secrets.SWIFTPATCH_ACCESS_KEY }}

CircleCI

# .circleci/config.yml
version: 2.1

orbs:
  node: circleci/node@5

jobs:
  deploy:
    docker:
      - image: cimg/node:20.0
    steps:
      - checkout
      - node/install-packages
      - run:
          name: Build bundle
          command: npm run build
      - run:
          name: Deploy to SwiftPatch
          command: npx swiftpatch release --platform all

workflows:
  deploy:
    jobs:
      - deploy:
          context: swiftpatch-credentials
          filters:
            branches:
              only: main

GitLab CI

# .gitlab-ci.yml
stages:
  - build
  - deploy

build:
  stage: build
  image: node:20
  script:
    - npm ci
    - npm run build
  artifacts:
    paths:
      - build/

deploy:
  stage: deploy
  image: node:20
  script:
    - npm ci
    - npx swiftpatch release --platform all
  variables:
    SWIFTPATCH_ACCESS_KEY: $SWIFTPATCH_ACCESS_KEY
  only:
    - main

Bitbucket Pipelines

# bitbucket-pipelines.yml
image: node:20

pipelines:
  branches:
    main:
      - step:
          name: Build and Deploy
          caches:
            - node
          script:
            - npm ci
            - npm run build
            - npx swiftpatch release --platform all

Best Practices

1. Use Environment-Specific Keys

deploy-staging:
  env:
    SWIFTPATCH_ACCESS_KEY: ${{ secrets.SWIFTPATCH_STAGING_KEY }}

deploy-production:
  env:
    SWIFTPATCH_ACCESS_KEY: ${{ secrets.SWIFTPATCH_PROD_KEY }}

2. Add Release Notes

npx swiftpatch release \
  --platform all \
  --description "Fix: Login button alignment on iOS"

3. Integrate with Slack

- name: Notify Slack
  uses: slackapi/slack-github-action@v1
  with:
    payload: |
      {
        "text": "OTA Update deployed: ${{ github.sha }}"
      }
  env:
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

4. Run Tests First

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm test

  deploy:
    needs: test  # Only deploy if tests pass
    runs-on: ubuntu-latest
    steps:
      # ... deploy steps

Monitoring Deployments

SwiftPatch CLI provides deployment status:

# Check deployment status
npx swiftpatch status --deployment-id abc123

# List recent deployments
npx swiftpatch deployments --limit 10

Conclusion

Automated OTA deployments reduce errors and speed up your release cycle. With SwiftPatch and your CI/CD platform, you can ship updates in minutes, not days.

Get started with SwiftPatch →

Ready to ship updates faster?

Get started with SwiftPatch for free. No credit card required.

Join Waitlist

Related Articles