Build Expo/React Native APK/AAB with Github Actions

Rayan Fernandes
2 min readNov 14, 2023
GitHub action building Android app APK/AAB artifact

Expo provides services to build your Android and iOS applications on their cloud, But the major drawback here is, that they have a maximum limit of 30 builds allowed per month.

To overcome this drawback, I thought of writing a GitHub action that will build the APK using the EAS build toolkit. This process took me a while to set up and I have documented the steps to be taken to create the build files and upload them as artifacts so we can download them.

Pre-requisite:

  • Github repo of your expo app
  • Expo account (Provides Token that is required by the EAS build tool)

After you have logged into your expo account, go ahead and create a robot token with admin access. This is required as the viewer or developer access tokens did not work and were giving permission errors during the build process.

Run eas init command and answer some basic questions, Once done , add the preview section as shown in the eas.json below

eas.json

{
"cli": {
"version": ">= 5.6.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"android": {
"buildType": "apk"
}
},
"production": {}
},
"submit": {
"production": {}
}
}

Here is the GitHub action file to build the app on GitHub servers and upload it as an artifact after completing the build.

android-build.yml

on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v3

- name: 🏗 Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn

- name: 🏗 Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}

- name: 📦 Install dependencies
run: yarn install

- name: 🚀 Build app
run: eas build --local --non-interactive --platform android --profile preview

- name: Upload Artifact GitHub Action
uses: actions/upload-artifact@v3
with:
name: assets-for-download
path: build-*.apk

The app.json configuration of my project

app.json

{
"expo": {
"owner": "myusername",
"name": "MY_APP",
"slug": "MY_APP",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "dev.myapp.studio"
},
"web": {
"favicon": "./assets/favicon.png"
},
"extra": {
"eas": {
"projectId": "5fafbba5-a3e3-4607-a6b5-5ad150a00132"
}
}
}
}

That’s all, now you can push your changes to the repo and the GitHub action will build the preview APK artifact.

Note: This APK file is to be treated as a preview only because we haven't signed the APK, those steps are skipped in this article. I’ll write about it once I have a final MVP of my app.

--

--