Automate Firebase App Distribution with GitHub Actions

Firebase App Distribution is a popular service for managing app testing versions, offering unlimited usage. This guide provides a simple setup for using GitHub Actions to deliver app versions efficiently.
Introduction
Automating the distribution of your Android app can save time and reduce errors. By integrating Firebase App Distribution with GitHub Actions, you can streamline the process of delivering app versions to your testers. This guide will walk you through the setup process step-by-step.
Firebase
Create a firebase project
Goto
Run > App DistributionSelect Android and fill the non-optional fields and proceed
Download the
google-services.jsonat the end of the setupSelect
Testers and GroupstabClick
Add groupand create atestergroup for app version should distribute
Google Cloud Platform
Goto Google Cloud Platform and select the project you just created at firebase
Goto
Service Accounts
Click
CREATE SERVICE ACCOUNTFill the service account name and id

Select the role as
Firebase App Distribution Adminand click done
Find the service account your just created and select
Manage Key
Create a new Key

Select a json key type then you will auto download the json key to local. It will be used when setting GitHub Action.

Android Project
Place the
google-services.jsonfrom firebase at projectapp/folder
Create a yml file
.github/workflows/firebase-app-distribution-action.yml
Setup the steps with following
name: Build and Distribute APK # Currently is manually trigger, you may change it based on your usage on: workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 # Change the JDK fit your project - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '17' - name: Set up Android SDK uses: android-actions/setup-android@v3 - name: Decrypt and set up Android keystore env: ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }} run: | echo $ANDROID_KEYSTORE | base64 --decode > keystore.jks - name: Build Release apk env: KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} run: ./gradlew assembleRelease --stacktrace - name: Get release file apk path id: releaseApk run: echo "apkfile=$(find app/build/outputs/apk/release/*.apk)" >> $GITHUB_OUTPUT - name: Upload to Firebase App Distribution uses: wzieba/Firebase-Distribution-Github-Action@v1 with: appId: ${{ secrets.FIREBASE_APP_ID }} serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }} groups: testers file: ${{ steps.releaseApk.outputs.apkfile }}Goto project
build.gradleand add pluginsplugins { //... id 'com.google.gms.google-services' version '4.4.2' apply false }Goto app
build.gradleand add plugins, dependencies and sign configs later on will ready for GitHub Action setupplugins { // ... id 'com.google.gms.google-services' } android { signingConfigs { release { storeFile file("../keystore.jks") storePassword System.getenv("KEYSTORE_PASSWORD") keyAlias System.getenv("KEYSTORE_ALIAS") keyPassword System.getenv("KEY_PASSWORD") } } } dependencies { //... implementation platform('com.google.firebase:firebase-bom:33.1.1') implementation 'com.google.firebase:firebase-analytics' }Sync and run the project once to ensure the dependencies and plugins version are match with your current project setup
Push the commits to GitHub
GitHub
Goto project repository's setting page
Goto
Secrets and Variables > ActionCreate following set of Repository secrets. We have defined them in our
firebase-app-distribution-action.ymlANDROID_KEYSTORE
CREDENTIAL_FILE_CONTENT
FIREBASE_APP_ID
KEYSTORE_ALIAS
KEYSTORE_PASSWORD
KEY_PASSWORD
Goto
Action > Build and Distribute APKworkflowClick run workflow if you are manually trigger workflow

Result
Once the workflow runs successfully, the app version will be uploaded and a notification will be sent to the testers group.

By following these steps, you can automate the distribution of your Android app using Firebase App Distribution and GitHub Actions, making the process more efficient and reliable.
