Github Actions + Fastlane + Firebase App Distribution

Wojtek Zięba
3 min readAug 2, 2020

--

If you’re using Github Actions and you want to automate the process of distributing your app to testers/QA team, you might want to use my Github Action for Firebase App Distribution or App Center. If you’re interested in writing your own action, I can recommend you my blog post: https://www.tooploox.com/blog/custom-github-action-for-firebase-app-distribution

Using custom Github Actions has its flows though. Two major are:

  1. Your CI/CD flow is tightly coupled with the Github platform. If you decide to change to any other CI/CD provider, you’ll have to rewrite a significant part of the flow.
  2. You can’t run your flow locally, which might be crucial for some use cases.

Using Fastlane as a middle-man

To decouple your CI/CD pipeline, one can use the tool Fastlane. Below you can see how we can merge those all services together.

The flow of Github Actions + Fastlane + Firebase App Distribution integration (see how happy QA/Testers are)

1. Github Actions

Firstly, you have to configure Github Actions workflow file:

Lines 4 to 9 describe workflow_dispatch manual triggers. This means, that this workflow can be run either by recently added UI widget or by REST call. Docs are available here.

This is how you manually run the workflow. Go to Actions > Distribute to firebase > Run workflow

Important note: you won’t be able to see/run this workflow until the .yml workflow configuration file will land to your main branch.

Installing firebase-tools

To allow fastlane to perform any Firebase-related operations, you have to provide Firebase CLI and put this into PATH . Usually, you could run

npm install -g 

but, as you don’t have root access while running Github Actions, you’ll receive Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules' . To not mess with permissions system, we’ll take an easier approach: we’ll use yarn and put its global bin directory to PATH . For details see this link, paragraph named “Adding the install location to your PATH”

2. Fastlane configuration

Assuming you already have basic fastlane setup (go with brew install fastlane && fastlane init ) you’ll have to add firebase plugin:

fastlane add_plugin fastlane-plugin-firebase_app_distribution

To use the new plugin, edit Fastfile . Minimal configuration is here:

In favor of keeping this as a minimal demo, I’m fetching some test .apk from remote and providing its path but instead of line 8 you’ll probably want to execute some scripts to build your .apk/.ipa files .

Offtopic: I was surprised by the behavior of thepwd command. Did you know that it adds a new line at the end of execution? That’s why we’re removing \n a character from it, before concatenation. Otherwise, we would land with malformed path to the distribution file.

Summary

That configured Github Actions workflow+ Fastfale will allow you to successfully run Fastlane lane and distribute .apk (or .ipa) to Firebase App Distribution. The sample code is available on Github.

--

--