CI/CD with Github Actions in ReactNative Android With Firebase Distribution
GitHub Actions gives developers the ability to automate their workflows across issues, pull requests, and more — plus native CI/CD functionality.
Prerequisites
Before diving into the tutorial, make sure you have the following prerequisites ready:
- A GitHub account.
- A React Native project.
- Firebase Account
Introduction to GitHub Actions
GitHub Actions are triggered by events. Common events include pushing commits, opening pull requests.
An event triggers a GitHub Actions workflow. Workflows can contain one or more jobs which are each a sequence of steps. The jobs can run in sequence or in parallel, but the steps within a job always run sequentially. In this article, each workflow has only one job.
Realtime Example
This is my github repository named Demo
First we create .github folder then inside create workflow folder and inside create yml file.
This is my yaml file
- GitHub Action Name: Give your workflow a descriptive name
name: 'Build Android app'
- Triggers: Specify the events that should trigger your workflow, like pushes, pull request merges, tags, or releases. Define these events in the on section of your workflow file .Here’s an example for triggering the workflow on pushes to the main branch
- Jobs: Jobs are sets of steps that run on specific runner machines. Name your job and specify where it should run. In this example, we have a job named build that runs on an macos-latest runner machine:
- Runner Machines: You can specify the runner machine for your job using the runs-on keyword. GitHub Actions provides various runner machine options, such as ubuntu-latest, macos-latest, or windows-latest. Here’s how you specify it in a job:
Step 1: Checkout Repository
This step checks out your repository, making it accessible for the workflow.
- name: Checkout repository
uses: actions/checkout@v2
Step 2: Set up Node
Set up Java
Setup android Release
After commiting Action tab look like below
And Finally Our apk generate automatically look like below
From here we download apk.
Now we distribute apk on firebase
Open App distribution on firebase
Then create tester group then add tester
Then install firebase tool globally
install firebase tools
the get firebase token using this command firebase login 📋
Then you get
Then add firebase token and app id on github
and appid,token,tester groups on workflow.
and commit your project
After Successfully you get get build on firebase
And you get email.!!!