GithubActions - Selfhosted Runners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video let us learn how we can use health self host around us with github actions before we start a quick introduction about myself so this is swaminathan Vetri I work as an architect at musk I'm also a Microsoft MVP and the developer technologies I tweeted until 8sv Swaminathan my github repositories are available at other 8sv Swaminathan my youtube channel is youtube.com slash for me nathanville tree and I also write technical blog that Swaminathan which we dot I n so the agenda of this session is going to be this let's start with an understanding of what our self or so runners and let's understand why we need them and it's also try to understand what are the differences between the github runners versus self hosted runners and when not useful for Citroen nurse right and then finally we will end up with a demo while setting up these as foreigners let's see how we can configure it how we can run a job in a cell for a runner and also it's finally the movie self or surrender right so what are self or certain nerves right as the name suggests you can host your own runners and then you can use your own machines with the operating system of your choice and then you can run the gate of actions on those machines that's what is typically a self hosted on that is it and how does that work so there is a there is an open source application called actions runner so that is being that has to be that is the one which is trying to establish the communication between the machine in which you are runner is running assess the one on the on the github side but what do you need self or sit on us in first place right so with github runner so if you don't have full control over the operating system or the tools is what is sir it's a for example if you're going to use an open to latest version which is managed by github you don't have a control over which version or so all right so if you want to have more control over the hardware and the operating system on the tools for example the dotnet version or whatever if you want to control everything then self faucet or Arno's are a good option for you and it also bring gives the flexibility for us to use your prating system which are not supported by or not provided by github runners it's of course all the major operating systems like Mac OS Windows or Linux are available with github runners but if in case you're looking for a specific version of Linux which is not there or so then you could vary you sell for sarin nerve and what are differences between these two right so obviously the get awareness or something which had managed and maintained by github at but sell foreigners it's something which we have to take care of everything right so only the I wanted to get a broader application is something which is maintained or which is created by github the rest all the operating system the hardware and software and all these tool sets and everything has to be run by us and talking about the updates perspective since it since the github runners are completely managed by github all the operating system updates are the tools updates and everything is taken care by them but here only the runner application which is the bridge between our one machine on the github is taken care by github but all other OS update let's say if you wanna update your Linux Ubuntu version or if you want to update your Mac OS version so on so forth it everything has to be taken care by us and the only other one of the second differences is with github runners every time a workflow is run and it is going to spin up a new instance so that means it's a clean instance which has been given but in the case of self or soreness that's not necessarily the case it's the same instance which is being usually used for each and every workflow run so if you want to maintain states between these different run source within self for sarunas are much beneficial for us and one other example where we could use is about the docker build site so where if you want to pre cache all your docker images or the different layers of your docker images then the self foreigners are much helpful there and the from the pricing perspective serve with github plan what are the free minutes you get that's what you would you can use initially I haven't uses github runners but once you exhaust those minutes it's all about permanent basis if let's say for building if you're running your workflows for 200 minutes then you would be charged for that particular minutes but in the case of self for soreness there is no running cost or build cost associated with the number of workflows or the duration of the workflow execution but what you end up paying is the maintenance cost for the infrastructure or the operating system or the tools and so on and so forth yeah and when not to use self or pseudonymous right so it brings a lot of flexibility for us it also comes with the caveat all right so if especially with the public repositories it's best not to use all foreigners because there's a possibility that some of the work could also run the malicious couldn't see a malicious code and that code in a hampered the cell for children or on also it also in she it also enables access to the emissions Network environment right because you are enabling communication between github where the code is hosted and the machine where you are trying to render and there are not here so that is a possibility that access to this machine that is the possibility that it has malicious code is that it can access these machines environment and potentially it could have some security risks and you might also end up persisting unwanted dangerous data in the machine so it so in this so especially for the public repositories it's it's better not to run this will force alumnus and late we can go with the github hosted runners if you're if you have full control over your management or if you have in your negative enterprise or team or so on so forth then you can have your self for under surveillance at up at the organization level or also you can set up at the individual repositories level so with that let's go go to the demo okay so for the demo we are going to use a basic dotnet core application so I've chosen the blazes over template application and so we're going to set up the github workflow for that for this application and enable the continuous integration build for this dotnet core application and this workflow it be running in in my local machine instead of running it from an and get a poster runner right and so if you're completely new to get up action such a code my other videos for the introduction to github actions and also understand how you can do that as your absolute deployment and as you're continuously container so is deployment and everything alright so let me quickly show the demo of what this application looks like and then we can go ahead and start setting up the workflows for this so I'm doing a dotnet run and when I browse this or just comes up and this is the basic dotnet core base place as our application so let's go ahead and start creating the actions for this right so I've already pushed this code into the repository and obviously it's a private repository here for all the reasons I mentioned the presentations have not enabled as a public so first things to set up the run alright so you have to go to the settings and then if you go ahead and click on the actions so you get you can see the options to add a hosted runner so there's a segment called self hosted runners so where you can go click on this add another button and then we can we'll have instructions to have the self assert under here so as we can see the supports for all these three different operating systems since I'm on my Windows machine I'm gonna choose Windows and I've already done the download part so what I'm going to run now is the only the configuration part so I'm gonna copy this script from here and then go back to my terminal and paste the command this would now enable me to you know add my machine as a runner into the github yeah so the name of the runners I'm gonna make it Swami - she went in that's my machine and any of the labels by default it large the label select self-hosted so I'm gonna say Swami nice elf holster ok and now that completes the runner part and the work folder I'm gonna leave it as a default city underworks underscore work and the next thing is to check if you want to make this another as a service so that wanders around making running as a service is that it log always be running in the background you don't have to worry about having a terminal open or not so I'm going to say yes for this and the user account I'm going to leave it as network service and yeah alright so now it would have set up the runner is basically up and running in my machine just to confirm we can go to these services so this is what MSE and then we can go ahead and check if it's available I think there is available now as we can see it up actions runner SV Swaminathan GA self also run our demos for me Wynton so this is my repository and this is the name of the runner what I have done and it's all running so now this should that means the runner is now connected to tab so let's go back to the github portal and then it starts creating the workflow so when I come here and I go to actions so to setup any new action click on this action tab and then you can see all the different templates available or you can also start from scratch so let let us see if there is something which is available for for a dock for a dotnet build right click on this more and there must be something for dotnet this is desktop ok yeah so there is one for dotnet core so I'm gonna say setup this workflow so now what this brings is it's gonna create a yeah Mel file within the github workflows folder and this is the steps what it is going to run so just to quickly summarize so it's trying to do on push off these or unpooled or concrete in a pull request for these branches this is this part is like the trigger here right if it's not very clear so this is where this segment is where this is the trigger of this workflow and this is a job job name is build and it's going to run on the ubuntu later so that's the that's that's what means it's this is basically a github hosted runner and we are going to run it down Ubuntu alright and these are the steps of what we are going to do first check out the code base and then me setting up the dotnet core version and then we are trying to you know we were trying to install the dependencies by doing dotnet restaurant then it is trying to do a dotnet build and dotnet test right in my machine I have 3.1.3 not once I'm gonna change the number here and by default when you may whatever the way armor feel you get it is going to have your github hosted on us so here is where we are going to use our tab our tag or the label so I'm gonna say run runs on self Foster and do a preview and now start commit pattered github flow file and say commit okay now if you go back to your actions it should ideally trigger this particular action and now when you go and click on the build let's try to set up the job so yeah so as you can see here it says switch okay this is sinking the repository and it's it's the the contents of this particular on it is time to run in here right see actions runner underscore work so that's the positive place where I have given in my machine so now this is getting triggered in this machine let's give it a couple of minutes for this to complete yeah I think it's it's almost done yeah so the job is completed and it ran in 51 seconds alright so if you can go around to the build so as you can see this is where basically the the build outputs and everything is there right so if you go back to the folder in my machine under github actions under the actions run at fold-over I've configured the runner so underscore work is where you see this in CSL for a runner demo so that's what we have it now so if you go open that this is where all the capacity or the entire repositories checked out here and the build and build has happened here right you can also go over and see all the actions whatever is mentioned in the in their workflow dot here into this particular folder so from from here on for every other workflow which is going to run it is not going to download the actions again it will try to reuse from this particular folder so now going back so this is somebody's if you now go back to the settings you should be able to see the runners mentioned they're good actions and you should be seeing Swami Wynton as a self-hosted owner and it's kind of idle now so when we are when the workflow is running it would have shown us running or whatever all right so that's is that's how easy it is to create a self-hosted runner and then attach it into github and then we can you know configure the workflows for yourself or so runners and if you want to remove it you have got two options the one you can go back to the terminal and then say configure command and then say remove and you need to provide token which you've used when you had provisioned this particular runner so I'm gonna paste that token here and in Stoppard oops okay I think there's an issue with the remove command okay so if other ways the other option is if you have to completely remove this entire runner from the repository can just go click on these three dots and then say remove and that's gonna remove your entire self first runner force remove this runner and done so that's it it's gone so now after this in this particular action file is going to fail obviously because we don't have a self force or under there so you might need to go ahead and update this workflow to use the Ubuntu lettuce or whatever the new tag or the label what if your going to go give the runners all right so yeah so that's pretty much what I wanted to show so we started with a basic dot and good application we created an workflow and we made it turn on the look on the self force Runner and we kind of tied on the runner as well thank you so much for watching this
Info
Channel: Swaminathan Vetri
Views: 2,648
Rating: 5 out of 5
Keywords:
Id: V_sG3N9qvuA
Channel Id: undefined
Length: 13min 52sec (832 seconds)
Published: Sun Jun 28 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.