logo
React Native Practical - Interview Questions and Answers
How do you set up CI/CD for a React Native project?
Setting Up CI/CD for a React Native Project

Continuous Integration and Continuous Deployment (CI/CD) automate building, testing, and deploying React Native apps. Below is a step-by-step guide to setting up CI/CD using GitHub Actions, Fastlane, and cloud services like EAS, Bitrise, or App Center.


1. Choosing a CI/CD Tool

You can set up CI/CD using:

CI/CD Tool Platform Best For
GitHub Actions Free for GitHub projects Custom pipelines
Bitrise Android & iOS No need for macOS
EAS (Expo) Expo apps Easiest setup
App Center Android & iOS Microsoft ecosystem
Fastlane Android & iOS Advanced automation

2. CI/CD with GitHub Actions

GitHub Actions is a free way to automate builds and tests.

Step 1: Create a .github/workflows/ci.yml File

Inside your React Native project, create the following CI/CD workflow:

name: React Native CI/CD

on: 
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build-android:
    name: Build Android APK
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Install Dependencies
        run: npm install

      - name: Build Android APK
        run: cd android && ./gradlew assembleRelease

      - name: Upload APK
        uses: actions/upload-artifact@v3
        with:
          name: app-release.apk
          path: android/app/build/outputs/apk/release/app-release.apk

  build-ios:
    name: Build iOS IPA
    runs-on: macos-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3

      - name: Install Dependencies
        run: npm install

      - name: Install CocoaPods
        run: cd ios && pod install

      - name: Build iOS App
        run: xcodebuild -workspace ios/App.xcworkspace -scheme App -sdk iphoneos -configuration Release archive -archivePath ios/build/App.xcarchive

      - name: Upload IPA
        uses: actions/upload-artifact@v3
        with:
          name: app-release.ipa
          path: ios/build/App.xcarchive

* This workflow :

  • Runs on every push to main
  • Builds APK and IPA files
  • Uploads them as artifacts for download

3. Automating Deployments with Fastlane

Fastlane helps deploy your app to Google Play Store and App Store.

Step 1: Install Fastlane
npm install -g fastlane
Step 2: Setup for Android
cd android
fastlane init

Then, create android/fastlane/Fastfile with:

platform :android do
  desc "Build and upload APK to Play Store"
  lane :deploy do
    gradle(task: "assembleRelease")
    upload_to_play_store(track: "production")
  end
end

Run:

fastlane android deploy
Step 3: Setup for iOS
cd ios
fastlane init

Modify ios/fastlane/Fastfile:

platform :ios do
  desc "Build and upload IPA to App Store"
  lane :deploy do
    gym(scheme: "App")
    upload_to_app_store
  end
end

Run:

fastlane ios deploy

* Fastlane automates signing, building, and uploading your app!


4. CI/CD with Expo EAS (For Expo Projects)
Step 1: Install EAS CLI
npm install -g eas-cli
eas login
Step 2: Configure EAS
eas build:configure
Step 3: Build & Deploy
eas build -p android
eas submit -p android

* This uploads the app directly to the Play Store/App Store!


5. Using Bitrise (No Mac Needed)

Bitrise is a cloud-based CI/CD tool for React Native.

Steps :
  1. Create a Bitrise accounthttps://www.bitrise.io/
  2. Connect your GitHub repo
  3. Add a new workflow for Android/iOS
  4. Start a build (Bitrise handles everything!)

* Great for teams that don’t have macOS!


Summary of CI/CD Tools
Tool Setup Time Best For
GitHub Actions Medium Free, custom builds
Fastlane Medium Play Store/App Store uploads
EAS (Expo) Easy Expo apps
Bitrise Easy No Mac needed
App Center Medium Microsoft ecosystem