Configuring Azure pipelines for OTA (over the air) updates using Expo EAS.

Configuring Azure pipelines for OTA (over the air) updates using Expo EAS.

  • expo
  • eas
  • azure devops
  • CI/CD
  • react native
published 2022-12-06

Although EXPO has a lot of information regarding OTA updates, they lack information on how to setup automatic updates using Azure.

In this post we'll look at how to configure Azure pipelines for Over The Air updates with Expo.

In this example pipeline we trigger the code below to run every time code is pushed to a specific branch. We setup node, checkout the repo and install our dependencies. Then we login to Expo using our username and an environment variable we called EXPO_CLI_PASSWORD. Lastly we specify the EAS branch and use the commit message as our update message.

Example pipeline

trigger:
  - (branch name)
pool:
  vmImage: 'ubuntu-latest'
 
jobs:
  - job: EAS
    displayName: 'Run Expo EAS update'
    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: '16.14'
        displayName: 'Install Node'
 
      - checkout: self
        displayName: 'Checkout repo'
 
      - script: yarn install --frozen-lockfile
        workingDirectory: '$(System.DefaultWorkingDirectory)'
        displayName: 'Install app'
 
      - script: yarn global add expo-cli
        workingDirectory: '$(System.DefaultWorkingDirectory)'
        displayName: 'Install Expo CLI'
 
      - script: yarn global add eas-cli
        workingDirectory: '$(System.DefaultWorkingDirectory)'
        displayName: 'Install EAS CLI'
 
      - script: npx expo login -u (your expo username) -p $(EXPO_CLI_PASSWORD)
        env:
          EXPO_CLI_PASSWORD: $(EXPO_CLI_PASSWORD)
        workingDirectory: '$(System.DefaultWorkingDirectory)'
        displayName: 'Login to Expo'
 
      - script: yarn run sourceEnvVariables && eas update --branch (eas branch) --message "$(Build.SourceVersionMessage)"
        workingDirectory: '$(System.DefaultWorkingDirectory)'
        displayName: 'Perform OTA update'
 
      - script: |
          # done
          echo 'EAS update on commit:' $(Build.SourceVersionMessage)

Note - it’s important to source your environment variables if you have some before running the update command.

Setting the EXPO_CLI_PASSWORD

We declare the variable to make it available in the script.

env:
  EXPO_CLI_PASSWORD: $(EXPO_CLI_PASSWORD)

Triggering an update

Since this example is set up to trigger when code gets pushed to a specific branch, you could for instance save this pipeline as ota-preview.yml and trigger it when you push code to a git branch called preview (which in turn is connected to an EAS branch with the same name).

Summary

OTA updates with Expo EAS are amazing and I hope you liked this article showing one way of configuring this process using Azure pipelines.

/ ND