A Simple Continuous Deployment of a React Native App to Google Play

Paulo Carvalho
3 min readJun 16, 2020

We will create a simple Github Action to build and deploy a React Native mobile application automatically upon pushing to a specific branch.

Photo by Kelvin Ang on Unsplash

Pre-Requisites

  1. A react-native application that builds successfully.
  2. An active Google Play account with the desired app already deployed (Google does not allow the first deploy to be programatic).
  3. A JSON key file for a service account user with access to the Google Play APIs. See how to create one here. Renamed to api.json and placed inside the android directory.
  4. A valid App upload key. See how to create one here.

Prepare for Secret Injection

To ensure authenticity, an uploaded application needs to be signed via an upload certificate that is password protected. In order to securely provide this password to our application at compile time we need to define it in our build configuration.

Edit the release certificate configuration in android/app/build.gradle by adding the following code block inside signingConfigs:

release {
storeFile file('upload-key.keystore')
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias 'bigdelivery-sales-app-upload-key'
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}

Then edit the line signingConfig signingConfigs.debug to signingConfig signingConfigs.release in buildTypes → release. These changes will allow us to inject the password for the upload key at build time.

Configure Fastlane

To ease integration with Google Play upload APIs we will be using Fastlane to build and upload our application. Fastlane needs to be configured locally before running it in our CI. For installation instructions on your local machine see here. To configure Fastlane, run fastlane init from inside the android application directory and follow the on-screen instructions. When asked for the location of the JSON key file enter api.json.

Edit the android/fastlane/Fastfile to include a deploy lane as shown below:

default_platform(:android)platform :android do
desc "Deploy a new…
Paulo Carvalho

Want to chat about startups, consulting or engineering? Just send me an email on paulo@avantsoft.com.br.