CI/CD for Android Projects using Github Actions | Pipelines + Workflows

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] today we are going to learn about CI CD pipelines and how we can utilize CI CD inside our Android projects so the first question we can have what actually this CI CD means so CI means continuous integration and CD stands for continuous delivery or continuous deployment now let's talk about our software development lifecycle process which we follow in almost every project so let's say a project has multiple developers different different developers can work on different different features and then they can combine all the code and release the build right so here we have this continuous integration we are developing something we are making some changes into the code either it can be we are adding some new features or we are fixing some bugs and then these changes we want to merge together and we want to deploy to our Google play or to our servers wherever our app is hosting right so CI can come into the picture here and whenever we are making some change or whenever a developer is making some change automatically these changes can be integrated into the main code base that is the main idea behind CI okay so if there is a developer who made some changes and we want to release those changes continuously CI can help us because all of the new changes it can integrate into the main code base okay and there we can initiate an automated process which can test that all the changes made are correct or if there are some UI tests or unit test we want to run it can also perform those action and then once everything is satisfied at this continuous integration process we can initiate continuous delivery or continuous deployment so if we are using continuous deployment so after continuous integration after we have validated the code we have generated one artifact either it can be APK or IPA file this generated file will be deployed to Google play or play store automatically but if we are talking about continuous delivery there will be one additional Step One reviewer will be there and after all of this process that reviewer will initiate the action to deploy so there will be one additional check that if you want to deliver a new APK file to Google Play we can do so in continuous delivery process and as we are talking about software development life cycle there are these three steps we develop a feature we test that feature then we deploy the changes to our Google play or play store right now CI CD can help us to enhance this process CI CD has a workflow and each workflow has these five things we have some kind of event event can be a push event or a PR or a pool event that means if user is doing something end user is pushing out the code which is kind of a event for our workflow okay and inside jobs we can write what to do inside our workflow if we want to create a build if you want to deploy a bill to the Google Play or something we can write inside jobs now we want to run our job let's say if we created a job to generate a Android build right so we want some kind of environment where we should run our application to generate build right so that is called Runner we can either use Ubuntu we can use LINE X we can also use some kind of java jdk versions and different different things to create an environment for our workflow to create one artifact then for each of these jobs we have multiple steps and action to execute inside our workflow I will show you all of these things when we write our first ever workflow for our Android project which will help us to create one build automatically and we have multiple tools to implement CI CD pipeline including Jenkins and now GitHub access and we are going to follow GitHub access for this video I am using GitHub access in few of my Android projects already and it is very helpful and let's start today's videos implementation Where We Are going to write one workflow to create one Android APK with the help of GitHub actions let's start so this is one brand new project which I have just created to show CI CD in Android application and as we are going to use GitHub actions so first let's create one GitHub repo and we will put this project inside GitHub okay so let's go to GitHub let's create one new Repository and we can just name it Android CI CD all right and we can just create one Repository and these are basic steps to just put our GitHub project here we can just go to our terminal in Android Studio we can just initialize one GitHub project we can add all the details and we can commit the project and we can just add the origin which is our repo link and we can just push the project to our Master Branch I prefer using Master Branch over main branch and now our code is pushed inside our GitHub repository now we need to create one workflow for our CI CD pipeline for that first of all let's convert this to project window panel click here and create one directory and you should be using the exact name for this directory Dot GitHub slash work flows okay we need to choose the exact naming convention and exact name for this directory now inside this workflow we can just create one file and we can call it Android build dot by ml we need to use this syntax dot by ML and we need to write all the commands all the jobs related to our workflow inside this file okay and this is going to be inside dot GitHub slash workflows and inside this we need to create this file we can also do this tab with the help of GitHub directory itself so this is our GitHub repo if we click on this actions button here it will show us one option to start with GitHub action so we have here multiple options either we can choose some popular templates or we can set up the workflow ourselves as well if we click on this it is showing us the exact same path which we have created right dot GitHub slash workflows and we have created the same dot GitHub slash workflows okay and inside this we can create any file with the help of dot by ML and it is also grading main road by ml so let's do one thing let's push this changes so we have already created this file as we have already created this ourselves we can just push these changes to our GitHub directory created GitHub workflow file okay and let's push this to our Master Branch all right now let's go back to our repo discard these changes as we have already created this file we have this dot GitHub slash workflow we can click on this and we can open the file we can click on this edit this file button and we can edit the code here as well or we can write the code in Android Studio as well so inside our DOT yml file we need to give a name for our workflow so we can just use this name and we can just give any name for our workflow we can write Android build okay this is going to be the name of our workflow next step is we need to Define one event means on which event our workflow should start so we need to Define one condition when our workflow should start so for that we need to use on and we need to Define few events here so we can say that on every pull request we want our workflow to start so we can use this pull request and inside this we can Define that on which branch our workflow should start let's say if someone reads a request to master branch that time we want to start our workflow so we can Define branches and we can Define Master Branch here we are saying that we want to start this workflow when someone trigger one event and that trigger is pull request and this pull request should be raised for master branch that time we want to start our workflow we can also start our workflow on multiple event so let's say we want to start on push event also if someone pushed some changes on Master Branch so we want to execute our workflow so for that we can Define the branches again we can just name it Master Branch so now our workflow will start on these two event pull request for master branch and push event inside Master Branch now we want to Define one job or multiple jobs which we want to perform inside this workflow to define a job or multiple jobs we can use this jobs and for now we are just going to write one job and which is going to use to build the APK for our Android project okay so we need to use this build and the first thing we need to write for any job is the system requirement so we need to specify that on which operating system this job is going to execute for that we need to use runs on and we need to choose any operating system either it can be Ubuntu or Mac OS or Windows OS we are going to use Ubuntu and we are going to use the latest one okay so we have written that this build job should run on Ubuntu system okay now inside our job we need to specify some steps which should execute okay so we are going to write steps and we need to write some actions now so the first step we would like to perform inside our workflow is to check out for the latest code then only we will proceed to the build part right first we need to check out the latest code so we can use some pre-built actions and GitHub actions has a marketplace where they have put out some pre-built actions okay so let's search for checkout action and this is by GitHub action so we are going to use this action itself we need to use these things okay so we need to write name and then we need to use this command uses so let's write these things we can just use one name and we can write checkout we can take the user's actions part and we can write it down this is the first step we would like to take inside our workflow now next step we would like to perform is we need Java SDK so we want to set up the Java SDK environment for that also we are going to use one plugin which is called setup Java jdk and this gives us one name and one huge case Okay so let's use this name setup Java jdk we can take this in next line and we can write its use case also so this is going to be the uses part all right now we have to step inside our workflow so we are checking out to the master Branch then we are done with our Java jdk setup now we need to build the project and to build the Android project we need Gradle support right so we are going to write one action for that and let's call it build with Gradle and it will run one command and this command is going to be the same which we use is to build our Android applications grade LW build so now after this step we are ready with the build now we need to upload this build somewhere right so let's use one another action called upload a build artifact this is also by GitHub actions so we can use this name upload a build artifact let's take this okay and we need to use this uses command as well okay so this action is used to upload a build artifact which is going to be the APK and this is the action so basically in short if I tell you that these actions are a command which is triggering a load of code inside but we are not having all of those details so these are the abstract code commands you can understand it like that so if we execute a command out of these action it will perform a set of operation and we will see the outcome we will see the result okay so inside this action we can use bid to provide some details let's say we want to provide some custom name for our Android APK so here let's say we want to pass the custom name or the project name so we can just take any name here we are just using project name dot APK okay inside path we need to provide the path where our debug APK will be located so we know that if we generate when debug APK our Android Studio generates one build under this path app underscore build underscore outputs underscore APK and our APK name is generally app debug dot APK all right so this is going to be our workflow we have defined one name for our workflow we have defined the events or action points which is push or pull request to the master Branch we have defined one job which is build the Android APK and it is running on Ubuntu we have also defined some step to check out set up the Java environment then we are building with Gradle and we are using this action to upload the artifact we are giving some custom name and path that where our APK will be located now let's push this file to our Android GitHub repo and let's see how it behaves okay so it should start basically one workflow for CI CD pipeline let's Commit This Define workflow for CI CD pipeline okay now when we push this it should trigger one workflow in GitHub actions now if we check inside this action tab so we had one workflow it started but it's failed so if we go inside build we have some error that input required and node supply distribution if you want to check more details we can click on this and it will show us the exact step that while we were setting up the Java jdk here we had some error so let's go back to our project and let's see build.gradle if we are using the Java versions okay we are using 1.8 let's use 17 and here as well in jvm Target as well let's use 17. and inside our DOT yml file let's specify some details so if we go to the GitHub and let's just open the workflow file let's open it so we have the actions right let's see that Java action inside this action we can provide some details with tag and we can pass the Java versions and some Java distribution these kind of things so let's update our Java jdk action we need to use with we need to pass Java version name okay we are using this Java version and we are using 17 so let's pass 17 now we need to also pass this distribution what what value we need to pass inside this we can check out inside its readme file let's search for distributions and we have some details okay here all the supported distributions are listed so let's use this adopt and it is going to use Adobe open jdk so let's use this tag first of all let's use it like this and we need to pass are doped okay let's remove this space now let's commit the changes so let me show you what changes we have made to fix this grass possibly first of all inside our DOT by ml file we have added these details with Java version 17 and distribution adopt and we have updated the Java 17 uses inside our build.gradle file as well okay let's push these changes using Java 17 in Project and workflow now let's push to our repo and it will trigger one workflow again so for that let's go to our project and inside actions we have one another workflow started let's click on this okay our build is in process let's click on this so our first step is successfully completed this time checkout is done Java jdk setup is done and we are at the stage where Gradle is building the APK okay we can check out the details so this is the job and it checked out to the repo then the Java jdk setup was done after that our build is in progress so we can see that this build with Gradle this action is also completed and if we check out the logs we can see that build was successfully generated in 3 minutes 37 seconds then we had upload a build artifact step as well if we click on this okay so the next step it is saying the path we provided is not having any APK so let me just check we have provided APK slash okay so we have two subfolder inside APK debug and release so we need to add debug folder as well okay so we need to provide the correct path as you have seen if we don't provide the correct exact path our build will not be captured right so let's update our repo once again and we are committing this time updated the yml file with correct build path and let's push this to master it will start one another workflow hopefully yes our workflow has been started let's go to the details and our job Side Up is done checkout command is already done Java jdk setup is done now Gradle is generating the build let's wait for some time okay finally our build is successfully generated so let's close this tab build with Gradle and this time let's open this upload a build artifact this step is also completed and this time we are seeing the message that artifact Android CI CD dot APK has been successfully uploaded because this time we have given the correct path and it is taking the name which we have given Android CI CD dot APK we can see it is showing the same name and it is saying that it has been successfully uploaded and after that it is just terminating the Java setup and everything and it is completing the job ok so if we just see the details if we just go to the project this time we have this green tick okay this means the latest commit has successfully completed okay if we just see inside actions so this is the latest commit where we have corrected the path it has been successfully completed and we can also see it has generated one build Android CI CD dot APK and if you click on this we can download the APK for our personal use or for our testing team okay we can click on this and we can see it's downloading one zip file and inside this we have this APK so this way we can set up our personal jobs to create builds to perform automatically all the unit test validation and other things a lot of things this way we can set up one personal CI CD for our Android projects so that's it for today's video I hope you enjoy this video if you enjoy this video please like share and subscribe to my Channel I will see you very soon with another video till then we you be happy also don't forget to mention your feedback in the comment section foreign [Music]
Info
Channel: Native Mobile Bits
Views: 8,815
Rating: undefined out of 5
Keywords: CI/CD, AndroidDevelopment, GitHubActions, ContinuousIntegration, ContinuousDeployment, DevOps, DeploymentPipeline, Learn to Automate Tasks for Android with CI/CD, Basic Continuous Integration with GitHub Actions for Android Developers, What is CI/CD Pipeline, Learn to create CI / CD pipeline for Android using GithubActions, Android CI/CD using Github Actions, NativeMobileBits, JetpackCompose Tutorials, Github
Id: uBXzaaOHVzY
Channel Id: undefined
Length: 24min 42sec (1482 seconds)
Published: Tue Oct 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.