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
Generating a CodePush Access Token.
Follow these steps to generate a permanent CodePush access token:
-
Navigate to your Profile Settings page. Locate the CodePush Tokens section.
-
Click Authenticate to complete the one-time authentication process for your account.
- Once authenticated, click Generate Token to create a new access token.
- Leave the expiration date empty to create a non-expiring token. Then click Generate.
- Copy the generated token which donot have any expire date and store it securely. This token can be used in your CI/CD pipelines without needing renewal.
Finding App Names for CodePush (Android & iOS)
To list all the apps registered to your CodePush account, run the following command:
appsonair-codepush app ls
This will display a list of available apps.
Identify and note down the app name you want to use for CodePush deployment. (Both Android and iOS)
CI/CD Environment Variables
Add the following secrets or environment variables to your CI/CD settings to enable seamless deployment with CodePush:
Variable Name | Description |
---|---|
APPS_ON_AIR_TOKEN | Your personal access token generated from AppsOnAir |
APP_NAME_ANDROID | Your Android app deployment name in AppsOnAir |
APP_NAME_IOS | Your iOS app deployment name in AppsOnAir |
Make sure these values are kept secure and are not committed to version control.
CI/CD Workflow Setup
- Github
- Gitlab
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
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 > Profile Settings > CodePush Tokens |
Update not showing on device | Version mismatch | Ensure -t matches app version installed on user devices |