Integration via CI/CD Pipeline
This section explains how to automate CodePush deployments using a CI/CD pipeline. By integrating CodePush into your CI/CD workflow (e.g., GitHub Actions, GitLab CI), you can ensure that every new release is automatically pushed to users without manual intervention.
Prerequisites
Before setting up automated deployments to AppsOnAir CodePush, ensure:
- AppsOnAir account and project set up
- Your app integrated with the AppsOnAir CodePush Depployment Key and ServerURL
- Your CI/CD system supports Node.js and shell scripts (e.g., GitHub Actions, GitLab CI)
Environment Variables
In your CI/CD settings, define the following secrets or environment variables:
Variable Name | Description |
---|---|
APPS_ON_AIR_TOKEN | Your personal access token |
APP_NAME_ANDROID | Your Android app deployment name in AppsOnAir |
APP_NAME_IOS | Your iOS app deployment name in AppsOnAir |
-
You can get the access token by using command
appsonair-codepush login
, this will redirect to a webpage where you will be able to generate access token. -
To find the app names (for Android and iOS), run:
Terminal
appsonair-codepush app ls
This will list all apps registered to your account.
CI/CD Workflow Setup
- Github
- Gitlab
.github/workflows/codepush.yml
name: CodePush
on:
push:
branches:
- main
jobs:
codepush:
runs-on: ubuntu-latest
env:
APPS_ON_AIR_TOKEN: ${{ secrets.APPS_ON_AIR_TOKEN }}
APP_NAME_ANDROID: ${{ secrets.APP_NAME_ANDROID }}
APP_NAME_IOS: ${{ secrets.APP_NAME_IOS }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "18" # Or your preferred version
- name: Install AppsOnAir CLI
run: npm install -g @appsonair/codepush-cli
- name: Authenticate with AppsOnAir
run: appsonair-codepush login --accessKey $APPS_ON_AIR_TOKEN
- name: Install project dependencies
run: npm install
- name: Deploy CodePush - iOS
run: appsonair-codepush release-react $APP_NAME_IOS
- name: Deploy CodePush - Android
run: appsonair-codepush release-react $APP_NAME_ANDROID
.gitlab-ci.yml
stages:
- codepush
codepush:
stage: codepush
image: node:18
variables:
APPS_ON_AIR_TOKEN: $APPS_ON_AIR_TOKEN
APP_NAME_ANDROID: $APP_NAME_ANDROID
APP_NAME_IOS: $APP_NAME_IOS
script:
- echo "🔧 Installing CodePush CLI"
- npm install -g @appsonair/codepush-cli
- echo "🔑 Logging in to AppsOnAir CodePush"
- appsonair-codepush login --accessKey "$APPS_ON_AIR_TOKEN"
- echo "📦 Installing dependencies"
- npm install
- echo "🚀 Releasing to CodePush (iOS)"
- appsonair-codepush release-react "$APP_NAME_IOS"
- echo "🚀 Releasing to CodePush (Android)"
- appsonair-codepush release-react "$APP_NAME_ANDROID" --platform android
only:
- main
Trobleshooting
Issue | Cause | Fix |
---|---|---|
Error: Missing app name | App name not passed or invalid | Make sure APP_NAME_ANDROID / APP_NAME_IOS are set correctly |
Invalid access token | Expired or incorrect token | Regenerate from AppsOnAir > Account > CodePush > Access Token |
Update not showing on device | Version mismatch | Ensure -t matches app version installed on user devices |