Build app with github-action and upload to Firebase App Distribution

Jerry Cho
5 min readJul 26, 2023

--

Often, having testers test apps can be a tedious task. But now, it’s much more convenient and even free. Below is how you can achieve this by using GitHub Actions and Firebase App Distribution.

Firebase App Distribution makes distributing your apps to trusted testers painless. By getting your apps onto testers’ devices quickly, you can get feedback early and often. And if you use Crashlytics in your apps, you’ll automatically get stability metrics for all your builds, so you know when you’re ready to ship.

GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

Play with following:

Part 1: Prepare your github project

Create a new github project or using your existing one
git clone your project to somewhere, like my working folder

At Android studio, create a project with below folder name

Click ‘Next’

Insert project base information, please written down “package name”, it will used for next step.

Click ‘Finish’

OK. your project was created like this

Part 2: Prepare your google cloud project at Google Cloud Console

always waiting …

After finish, You will see like this

Part 3: Prepare your firebase project

Go to your firebase console:

Add Firebase project
Simple select Default Account
waiting ….
Yeah, created, and click ‘Continue’

Part 4: Add Firebase to your Android App

Click ‘Android’ icon

Package name should be same with above step!

Following the step to add firebase into your project

After create a firebase project, you will see this screen. And then click your Android project

You will see you App ID, like 1:xxxxxxxx…:android:xxxxxxx…. , please write it down for next step use.

Setup test user account at your firebase console

Part 5: Get firebase token

Login firebase CLI

  1. install https://firebase.google.com/docs/cli
  2. login with your account
firebase login:ci
Allow here

After “Allow”

Part 6: Prepare the key(s), which is used for build the app and deploy to firebase distribution.

We are using https://github.com/wzieba/Firebase-Distribution-Github-Action to help to deploy our app to firebase distribution.

  1. appId: Got from part 2 already
  2. serviceCredentialsFileContent: step from https://github.com/wzieba/Firebase-Distribution-Github-Action/wiki/FIREBASE_TOKEN-migration
    (Remark: there have some unknow result cannot use)
  3. token: Got from part 54+ already

Part 7: Step up github action file

Go back your github repository. Add two key:

  1. FIREBASE_APP_ID
  2. CREDENTIAL_FILE_CONTENT
  3. FIREBASE_TOKEN
Add ‘FIREBASE_APP_ID’ key
Add ‘ CREDENTIAL_FILE_CONTENT ‘

Finally, you will see like this

Part 8: Create“android.yaml” to let github action know to build

Create android.yaml” into your android project, and stored at

Sample of android.yaml

name: Android CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: build release
run: ./gradlew assembleDebug
- name: upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1.5.1
with:
appId: ${{secrets.FIREBASE_APP_ID}}
#token: ${{secrets.FIREBASE_TOKEN}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: app/build/outputs/apk/debug/app-debug.apk

Part 9: Finally step

  1. Commit and push your code to your repo.
  2. You can check the build result at your github

👏 Congratulation, you will got this email when built is successful 👏

--

--