How to configure self-hosted runner in GitHub Actions | Self-hosted build agent in GitHub Actions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back in this video we are going to learn how to configure selfhosted runners in GitHub actions what are all GitHub Runners so GitHub Runners are nothing but build agents where you can run your CD workflow if you're using GitHub actions uh GitHub actions provide two different type of Runners primarily you can go with the GitHub hosted Runner or you can go for selfhosted Runner they also have large larger Runner as well where you know the sizing is really huge if you wanted to or they also have you know Emeral self hosted Runner primarily like they're all on demand okay but the scope of this particular video we are going to talk about how we can configure a selfhosted runner try to compare selfhosted Runner with the GitHub hosted Runner um like GitHub hosted Runners are nothing but they're all completely provided by GitHub itself the build agents provided by GitHub itself so GitHub manages the entire infrastructure they also have various typee of uh you know uh Runners it could be wub to Windows and toss you name it right they have all kind of you know GitHub Hoster Runner you can run your workflow pretty much on any any type of operating system right all you have to do is just mention the label and then boom you know you are done okay but let's say that you want to have more control over the build agents then you can go for something called selfhosted Runner so that's exactly what we are going to talk about in this video so this is my website folks coach devops.com I would be posting the link right below the video as well all right so so let's look at this diagram right so you can configure selfhosted Runner pretty much anywhere you can set up selfhosted runner on premises or you can set up in AWS cloud or Azure cloud or pretty much any popular cloud providers out there or you can also run selfhosted Runners as Docker Emeral containers as well okay but the scope of this video is we are going to pick up a ec2 instance in AWS cloud and then we are going to configure uh you know we're going to configure that E2 instance as a self hosted Runner and then we will pick up a Java project configured in GitHub and then we will just Implement a basic CSD workflow great and then what what are the other advantages of self fored Runner so pretty much what we just talked about right if you want to have full control over your environment and tooling and then if you want to have your own custom configuration right and then uh let's say that you know you don't want to worry so much about uh you know any firewall issues or anything like that if you want to really have uh secure access you don't want to worry about any kind of firewall issues or anything like that then you can go for self hosted Runners isn't it so let's get started let's look at the prerequisite yes we need to have project configured in GitHub so if you see here this is a sample Java project so we have configured in GitHub and we are going to uh create a CD workflow and we are going to use a self-hosted runner in order to you know build this Java project using Maven uh so that's exactly what we are going it's a very simple workflow I just wanted to demonstrate okay and then we will also create a workflow AML file and we will check that in GitHub and if you don't know how to create it I have provided a small article here if you wanted to uh learn how to create a you know CSD workflow using GitHub actions feel free to go through this particular article so this is the workflow Amal file okay and then we are going to uh use our ec2 instance so I have already created one E2 instance which is up and running in AWS Cloud so we are going to configure uh GitHub actions run runner on this particular ec2 instance okay and then of course we also need to install mavan as well because the runner is going to use Maven for building our Java project so how do you create a selfhosted runner so like I said we are going to use this ec2 instance so I'm already connected to my ec2 instance I just created this you know brand new ec2 instance so this currently does not have anything installed you can see here right so I don't have anything installed Java or anything anything I don't have anything installed just uh sorry so it doesn't have anything right okay so I'm going to show you how we can run Builds on that particular easy to instance okay so we need to go to our repository so this is my repository and then go to actions or you can also go to settings go to settings click on actions and then click on Runners so as you can see right right now we don't have any self-hosted Runner okay so click on new self-hosted Runner and then what is our runner type so we are going to use our ec2 instance isn't it so I'm going to select this one and then look at the beauty right so GitHub is providing all kind of uh you know documentation uh you know on how we can configure runner on our ec2 instance okay so I have put together all the steps over here so let's try to execute everything one by one okay so the first thing first let's start with the sud update because this is like like I said brand new2 instance I don't have anything installed but let's start with U you know updating our ec2 instance and like I said guys you know you can configure uh your selfhosted Runner pretty much anywhere but this particular video we are going to just use AWS Cloud all right great so the update is done and then let's also go ahead and then install Mayan as well because like I said uh we are going to run um you know Java build right okay we are going to uh build our Java application using Maven so that's the reason why I'm installing Maven but again depending on your technology stack you can install you know the the the required build tools great so Maven got installed perfect so now let's go ahead and then configure our runner so let me go ahead and then create this uh folder right now and then as you can see here we need to download the installa bles so again everything is provided over here so if you see here it comes as a tar file all we have to do is you know just download them and then extract them so let me copy this one there you go so we were able to download the tar file and then let's go ahead and then extract the tar file so let me perform this particular command perfect so this has been extracted and then let's go ahead and then configure the runner but again like I said all the steps have been documented here so they also created the token here as well all you have to do is just copy this command and then go ahead and then run it so what this will do is this will start configuring a runner on this easy to instance so right now it is actually asking for the name of the runner group okay but uh you know I I don't want to worry so much about it I'm going to go ahead and then press enter this will actually create a default Runner group and then if if you want to provide a name for the runner you can actually do that but let me do one thing let me go ahead and then say EC to Runner okay Enter okay and then if you want to have any kind of uh labeling you can also go ahead and then provide that uh but let me see here I'm okay to to provide the same name easy to Runner enter so that's it right so now as you can see here uh runner has been successfully uh configured now it is asking to provide a work folder I'm okay with that name underscore work so let me enter that so perfect right so right now the runner is configured as you can see here so all we have to do is now go ahead and then run it so how do you run it just EX good I mean again if you want to see here uh you see here right we since we have extracted here all the files are here so now let's go ahead and then run it so this is the command what we are going to perform run. sh perfect wow look at here guys what does it say it says that connected to GitHub now our runner is waiting waiting for the jobs isn't it so how do you confirm that let's go back to our GitHub and then then let's go to Runners click on here wow there you go guys do you all see right now so this was the label what we gave right so obviously right now we don't have anything uh we don't have any job running on this particular Runner so that's why it is actually in the idle State perfect right so we have successfully configured so now let's go ahead and then create some basic uh you know workflow AML file and then let's go ahead and then run the build okay so how do you do that like I said uh you know I have a separate article if you wanted to learn if you wanted to learn how to create a workflow Amal file feel free to you know uh do that but I have already done that so I'm going to go ahead and then simply copy and paste just to save time so go into code so we need to create that workflow file isn't it so click on ADD file create new file so we need to say dog Hub slash uh it has to be workflows folder slash and then give a name of the AML so I'm going to give cicd do AML file and then go ahead and then copy and paste the content you see here uh the branch name is main obviously right so the branch name is main I think I I can show you the branch name okay and then um so this is the most important thing right selfhosted if you wanted to refer uh GitHub Hoster then you would be providing something like UB to latest or something like that right and then this particular workflow is primarily having three major uh task right I'm checking out the code setting up Java and then you know building with Mayan that's it right so let me go ahead and then commit changes here so I'm going to say create CS DL file uh just commit and you can see here right that's the branch name and that's exactly what I have over here so now we were able to check in the code and you can see here the build is already running so go to actions there you go the build already started isn't it and you can literally see here right now there you go look at here guys and they also tell you what is the machine name and everything so that is our mission name isn't it 172 3133 wow so since we are running the maven build for the very first time so it is actually downloading all the dependencies uh so when you run the build next time uh you know it is not going to download those dependencies again right so that is also another uh you know difference uh you know using GitHub hosted versus selfhosted isn't it perfect I think the job is done right now and I look at here right so pretty much everything is uh you know ran and then of course you can also see that here as well job completed and the result and whatnot so so let's just go go back right there you go and you can you can see right now right the build is done yeah so yeah this is really pretty uh straightforward guys so this is how guys you know this is how you can uh configure selfhosted runner in GitHub actions thank you for watching
Info
Channel: DevOps Coach
Views: 2,457
Rating: undefined out of 5
Keywords: GitHub Actions Self-hosted runner
Id: I3WwhhkQogA
Channel Id: undefined
Length: 12min 37sec (757 seconds)
Published: Tue Feb 27 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.