In this lecture, let’s setup Git and CodeCommit repository to setup Source Control for our 1
serverless web app frontend. 2
So, let’s open CodeCommit… 3
And we’ll create a new repository… 4
We have our existing repositories here… let’s create a new one. 5
We could name it, SLS Notes Web App Repo, for example. 6
And hit create… 7
We can skip this step… as usual… and in here, we have the repository URL. Before we 8
can use that, we must first setup a local GIT repository in our project. 9
So, back to VS Code… Let’s first build our application for production. So, we run, 10
NPM Run Build COLON Prod… and you can find this command right inside the package Dot 11
JSON file. 12
So, let’s run this command to build our project for production deployment. 13
Once that’s done… we can go ahead and initialize a local git repository with GIT 14
Init. 15
GIT status will show us the current status of the repository. Let’s add all these files 16
to GIT with GIT Add DOT… This is going to add all the files from the project folder 17
to GIT, except the ones specified in the DOT Git Ignore file. So, here we are ignoring 18
the NODE Modules folder. So, except that folder, we want to add all the remaining files to 19
GIT. 20
Let’s run GIT Status again… and we see all these files are now showing up as green 21
and can be committed. 22
And we’re on branch master… 23
So, let’s run Git Commit DASH A M, with message as First Commit and hit enter… 24
Git status… tells us that we’re on master branch. 25
Before we push our changes, we must add the CodeCommit repository as the GIT remote… 26
So, we could say, Git Remote Add Origin… and then copy the CodeCommit URL from CodeCommit… 27
Copy just the URL and not the entire command… 28
And paste it in here… 29
So, we setup the remote… and if we now run GIT Remote DASH V, it should show up the details 30
about the remote. 31
We can now push our changes… with Git Push… and we’ll also setup the upstream as this 32
is our first commit… so we say, Set Upstream… Origin, Master… 33
This is going to push our code to the master branch on our CodeCommit and also 34
associate the local master branch on the computer with the remote master branch on CodeCommit. 35
So the next time we push, we don’t have to use this long command like Git Push Origin 36
Master… we can instead simply push using Git Push. 37
Similarly, let’s create a dev branch as well. So, we checkout to a new branch called 38
Dev using Git Checkout DASH b, Dev. 39
Confirm that with Git Status… and we are in deed on the dev branch. 40
So, we can go ahead and push this new branch to CodeCommit. So, we can say, Git Push, Set 41
Upstream, Origin, Dev… and hit enter. 42
That’s it. We’re done. And we have our application code pushed to CodeCommit. 43
So, let’s go back to CodeCommit… and refresh… 44
And our code is showing up here as expected. 45
We have these two branches… dev and master. 46
And if we go to Branches… we can see that the master branch is the default branch. 47
So that’s about it. The next step is to setup the CI/CD pipeline to automate the deployment 48
process. So, let’s do that in the very next lecture. I’ll see you in the next lecture 49
in just a bit.