A Simple Continuous Deployment of a React Native App to Google Play
We will create a simple Github Action to build and deploy a React Native mobile application automatically upon pushing to a specific branch.
- A react-native application that builds successfully.
- An active Google Play account with the desired app already deployed (Google does not allow the first deploy to be programatic).
- 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.jsonand placed inside the
- 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
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.
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
android/fastlane/Fastfile to include a deploy lane as shown below:
default_platform(:android)platform :android do
desc "Deploy a new…