How to deploy automatically a new website with the GitHub Actions

How to deploy automatically a new website with the GitHub Actions


Bonjour hi welcome to this new episode of
cloud in five minutes I’m Frank Boucher and today I want to show you how to use
the new github actions to deploy a brand new website in Azure [Message in French] so you heard about those new github
actions and since you’re just starting a new project you would like to use it for
building a CI CD and deploying your website in Azure that’s the video you
need to get started so I will be using dotnet core because I’m comfortable with
c-sharp but you can do it with no than many other framework as long as the code
is in get up to get started let’s create that website in that net it’s very
simple that knit new blazor server of course that will be using blazor I will
create the the application in a subfolder so that’s perfect for me and
you know what I will also add a getting more file because I completely forgot so
add get ignore I will use the or is it vs code where is it is real still code
perfect so now I have my get ignore file fight
close the terminal perfect so now I have my getting or file I have my application
let’s change it so we know it’s our own website so we’ll go in page and I will
go in the index and I will let’s scroll down this and instead of hello world
let’s put something that is a little bit us right so we’ll do Bonjour hi Polly’s
excellent so I save and now I’m ready to push great so I just pushed it and get
up so let’s have a look so we go and get and now I have it
it’s my code so now what I want to do is go in action here and now you could
start with a template or you could build your own to get started have two links
just prepare for you so the first one is bitly slash web apps – deploy that’s the
documentation from get up it will get you the template so we’ll get more into
that and the second thing I prepare is more D in
traction the step-by-step from the documentation in Microsoft website so
it’s a bitly slash action – web app okay so all the link will be anyway in the
description down below so what I need right now is take this dotnet Yama file
and we’ll use it in our solution but before I can use it I need to create a
new folder get up flow here so let’s go in our folder
we’ll create a new folder and it will be that get up so get up we’ll know that
it’s an instruction for for him and I want it at the root level voila
and now from this thing I want to create workflows so work flows just like this
and now I will be able to create a new file so a new file and I could say I
sure that llamo and now I can copy/paste the template I need for me right now
dotnet is a good starter start point so let’s start from there and we’ll see
what we need to change so let’s have a look and then we’ll see because we
cannot really use that one exactly so the template here it’s very simple it’s
specified that on a push or a pull request that that action will be
triggered and then we have one job so we’ll build and deploy that’s the name
of her action and it will run on the latest version of Ubuntu now we have
bunch of steps so the first one will be to check out the code from the branch
master so that’s pretty cool from there and now what we need is set up that net
core because right now we’re just created a new instance of Ubuntu there’s
nothing if you have node you need to install node you install node I need net
course or that is just action set up that net and I specify the version so
right now it’s version 2.2 I think my version is more require
three so I will need to change that it will change everything after I explain
so and then what I do have another step where I will be buildings or done net
build and see here it it thinks it’s already in the main folder but I always
try to keep my separate life my application in a subfolder see here if
we go back in the project and the code I have subfolder and I will create a new
folder deployment two kind of keeping everything structure so we need to
change that and I will show you how to do it it’s very very simple and then
same comments I will be doing a dotnet publish using the configuration release
and the output will be in my app and then that’s the interesting part it will
be deploying using a func emitted using web deploy when in required that the web
app already exists so if that’s what you’re looking for I will have another
video and it will be available in the corner here another video where I show
you how to create a CI CD on an existing web app but right now we don’t have the
website that exists in Azure so we need to also create the resource in Azure so
this is why this template doesn’t work for us so let me show you what I have
prepared for you I just could be pasted the new let me show you few stay a few
things so first I use environment and I’m not using it everywhere I just want
to show that you could use the environment variable because I think
it’s easier when those instructions or like the name of the app and thing like
that or declare at the top so it kind of helped a little bit to make your
template reusable so then same thing we use a job have multiple step so here
again and I need a different version I need 3.0 so right now the actual
version is treated 0.11 so that’s the one we’ll be using and now I will be
building the the application but I need to specify the folder so this is really
simple I just need to put it here and I won’t be
defying the folder where it needs to be doing this stuff right so now here what
I want to do is create the resources in Azure and for that I will need to give
permission to get up to access my subscription we’ll do that by creating
an identity service principle in in Azure and then saving those information
in the secrets I never used secrets and it was the first time and it’s very easy
just some variables that are hidden available and get up and you just do
like those dollar sign double curly brackets secret and this is the name of
your secret and in fact it’s just a JSON object with you pasted there and it’s
used by that action and this action what it will does will run to come in in
Azure CLI so it will excrete a new resource group because yes we need a
resource group and then it will deploy an arm template that will be available
and deployment to create the resources that file doesn’t exist so we also need
to create that and then same thing what I will be doing it will just be
deploying that web app and that’s it and because I’m attenti cated because I did
here the action login that’s when I’m using my subscription and things like
that so I don’t need to do anything special for this and then I I log out
here so now what we need is to create or service principle will we be doing it in
an azure CI we you could do it also by the portal just want to use a function
so let me explain so easy because I’m calling the azure CLI it an ad because
I’m talking to the Active Directory service SP for service principle and
then I will create for a role RR back service I give it a name so my
application will be called Cloud five net Frank demo and then I assign the
contributor the role contributor is you could do whatever but you cannot give
permission to others so that’s fine and then I define the scope so because I
don’t have the resource group that already exists I don’t have any website
that already exists I need to give permission a little bit more broadly so
I will be specifying the here the ID of my subscription and then I specify using
the SDK identification perfect so now we’ll be using so I just open the
terminal and I will paste this information we’ll get the information
and now I have the information I need so I will take this it’s a JSON file right
so I’ll just take this and then I’m gonna go in the portal and we’ll go in
setting and now I need to create a secret so a secret is here in the the
setting so I click secret now okay I click the add new secret and I will
paste my information and I need to put it in the azure credential and because I
don’t want to do any typos I will just do this so voila
and I will add secret so now my information is there it’s available I
can refer to it so what’s missing right now is we need our army template because
right now everything is there but we need to create a resource in Azure so we
can deploy the code in it so we need to create a new folder named deployment and
a new file so first we’ll go we are at the root
level exactly and here and I will create a new folder called deployment I will
just take the name here and inside deployment where is it it’s here I will
create a new file name as your deploy perfect so as your deploy now it’s a
norm template so I will specify here that it’s an Asscher resource manager
template and I’m using here 2x mention that are fantastic when you do
this the arm template resource manager tool and the arm template snippet so
those tool are awesome when you’re creating a template i really suggest to
install them I will put again the link in the description so now what I need to
do is create a new arm template to do this you just type arm with the
exclamation point now I have an empty arm template for a website
I need a service plan and a web app I will go here in resource perfect and now
let’s create a service plan so I will just say arm and then plan voila
and it won’t be Cloud five minutes demo – plan and I have nothing else so I save
and now I can add the new resource so I need the website I just do arm and it’s
web app so web app just here and now I need to give it a name so the name of my
resource will be Cloud five minutes demo I said demo voila
and now the service plan is I need to enter the same name so it was Cloud five
minutes they know that and I’m good and I just need a comma because I have to
resource so that’s my arm template of course look of course in a real life I
will have variables and things like that but since it’s just a demo this is good
enough for me so now I have it have my arm template define of the llamó with
everything they find here so it should work so here the secrets credential will
go get my secret I have the folder it’s there so everything should be good so we
just need to push it and see if it’s working so we’ll commit everything so I
push I commit and I push voila now to see what’s happening we go in get up
there it is and if I click now on action I should see my action
I’d get trigger it’s running and I’m going to look at it so once it will be
done I’ll get back to you and we’ll look what happened you okay so I did it again because the
resource group name already exists so I just changed and added to so you can see
here I have the cloud five minutes to that exist so now everything look like
it worked so we have all green check so it’s good right but let’s go in the
portal see exactly what I’ve been created and we should have here called
five minutes to and now I have it my web app let’s create it in my service plan
that is created and if I go here to the website yeah so Bojo hi cloudy’s that’s
our website but I would like to see also what else did we create so we see here I
have the service plan so service plan is all the resources that are defined for
us where you could scale and things like that
but remember we created some resources in the active directory so let’s have a
look to this so to go there I will go and go in active directory if you don’t
see active directory they’re just so go for all services and search active
directory it should be not very far active directory just here and now to
see our service principle you will go in the application registration and if I
type the name our application I have it here the get up with the application ID
and if I click on that we’ll have all the information so I have all the role
in permission and here at all this talk if you want to know more about how to
implement the security in your web app using a logon and stuff like that you
have a lot of information in here or I already have also another video about
that that you can have a look where I use the logon in the net core but see
you could do it with many different application so that’s pretty cool so now
we have it and every time we’ll be doing a check in the application will be
compiled and redeploy in Azure using our get up function action so I have a more
and more questions in the comment section so I decided to answer a few
questions live on stream so feel free to add more if you want to see your
so here I have oh yeah that wasn’t was interesting so what so what if you don’t
want to use Azure so it was about it was about Asher Active Directory so it’s
good since I’m talking also about Azure Active Directory today so what if you
are not in Azure well whatever you’re deploying an application on pram or
whatever you could still use Azure Active Directory if you’re unfamiliar
don’t want to use Active Directory you could use any ad doesn’t need to be a
sure Active Directory or you could use app or any kind of social media so
there’s plenty of solution would net for authentication or in Azure different
kind of things so another one is in this video where I was talking how to search
like a bus so I add someone from the grafting saying that my video is
wonderful thank you and also someone who wears it oh there’s the new graph
explorer that exists thank you it’s true I completely forgot so I like you when
guys you get me back on track so thank you thank you a lot Umesh mean
so last comment from i’m getting old a last comment from i’m ed that’s a cool
video do more about as your functions higher you more to come so that’s it for
today I hope you like this video and I hope it was useful don’t a state to ask
any questions in the comment section I’m always very happy to answer you and as
usual don’t forget to subscribe like share click the bell icon so you know
when I’m posting and I see you in the next video thank you for watching
you

Comments

  1. Post
    Author
  2. Post
    Author

Leave a Reply

Your email address will not be published. Required fields are marked *