13. Source Control
Tags: aws, github
Published: 2021-01-06 21:48:41

After creating the source code for frontend and backend of my [bio](http://blog.komlalebu.com), it was time for setting up the source control for efficient code tracking and maintainence.

![Alt text](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftettra.co%2Fwp-content%2Flogos%2Fgithub.png&f=1&nofb=1)

#[Prerequisites for PC](https://code.visualstudio.com/docs/editor/github) 
[VSCode](https://code.visualstudio.com/Download)
[Github](https://desktop.github.com/)



#[Source Control](https://aws.amazon.com/devops/source-control/)
Source code management systems allow you to track your code change, see a revision history for your code, and revert to previous versions of a project when needed.
You can either use [AWS CodeCommit](https://aws.amazon.com/codecommit/) or [Git](https://github.com/) for this purpose. I chose Git for this website.

#[Github](https://github.com/)

For continuous integration and deployment, or `CI/CD` of my sources I created two repositories for my frontend and backend.

# CI/CD Frontend git repository : [read more](https://dev.to/jicoing/15-ci-cd-front-end-1626)

Git: https://github.com/jicoing/git-komlalebu
* I created a git repository by the name `git-komlalebu` in Github and cloned it to my local with the URL.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qte0jz1svcquf53skz4f.PNG)

>CMD

                   >git clone https://github.com/jicoing/git-komlalebu.git

>The basic tree structure should look like this.
With `index.html`, `styles.css`, `error.html` and some image files for my website under the root.
>Folders:
`workflows` - Needed for Github actions**. [Read more](https://dev.to/jicoing/15-ci-cd-front-end-1626).
`Actions` - Needed for Github actions**. [Read more](https://dev.to/jicoing/15-ci-cd-front-end-1626).  

                    >C:\Users\USER_NAME\git-komlalebu>tree

Tree:

git-komlalebu
 ┣ 📂.github
 ┃ ┣ 📂actions
 ┃ ┃ ┗ 📂sam
 ┃ ┃ ┃ ┗ 📂package
 ┃ ┃ ┃ ┃ ┣ 📜action.yml
 ┃ ┃ ┃ ┃ ┣ 📜Dockerfile
 ┃ ┃ ┃ ┃ ┗ 📜entrypoint.sh
 ┃ ┗ 📂workflows
 ┃ ┃ ┗ 📜main.yml
 ┣ 📜error.html
 ┣ 📜git.png
 ┣ 📜hilltop.PNG
 ┣ 📜html.png
 ┣ 📜index.html
 ┣ 📜Komladefault.png
 ┣ 📜Komlaprocesslogo.gif
 ┣ 📜README.md
 ┣ 📜squirrel.png
 ┣ 📜styles.css
 ┗ 📜whale.png


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ii0z3uqy1ostxr42kmkx.PNG)

* Then I pushed contents of `C:\Users\USER_NAME\git-komlalebu` from local to my git [repository](https://github.com/jicoing/git-komlalebu).

>CMD

                 C:\Users\USER_NAME\git-komlalebu>git add .
                 C:\Users\USER_NAME\git-komlalebu>git commit -m master
                 C:\Users\USER_NAME\git-komlalebu>git push origin master

[git-add](https://git-scm.com/docs/git-add) - Add file contents to the index.
[git commit -m master](https://git-scm.com/docs/git-commit) - Record changes to the repository. 
[git push origin master](https://www.javatpoint.com/git-origin-master) - pushes the code to master branch.


# CI/CD Backend git repository : [read more](https://dev.to/jicoing/14-ci-cd-back-end-2eid)

Git: https://github.com/jicoing/git-komlalebu-sam

* I created a git repository by the name `git-komlalebu-sam` in Github and cloned it to my local with the URL.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sx7bd0s085gzjg22hmmb.PNG)

>CMD
 
                         >git clone https://github.com/jicoing/git-komlalebu-sam.git

>The basic tree structure should look like this with `template.yml` file and `komlalebu_function` folder under the root of the directory.
`template.yml` - has my SAM template.
`komlalebu_function` folder - has app.py python code that goes into my lambda function.
>Folders:
`Workflows` - Needed for Github actions**. [Read more](https://dev.to/jicoing/14-ci-cd-back-end-2eid)
`Actions` - Needed for Github actions**. [Read more](https://dev.to/jicoing/14-ci-cd-back-end-2eid)

                        C:\Users\USER_NAME\git-komlalebu-sam>tree

Tree:

git-komlalebu-sam
 ┣ 📂.github
 ┃ ┣ 📂actions
 ┃ ┃ ┗ 📂sam
 ┃ ┃ ┃ ┗ 📂package
 ┃ ┃ ┃ ┃ ┣ 📜.gitignore
 ┃ ┃ ┃ ┃ ┣ 📜action.yml
 ┃ ┃ ┃ ┃ ┣ 📜Dockerfile
 ┃ ┃ ┃ ┃ ┣ 📜entrypoint.sh
 ┃ ┃ ┃ ┃ ┣ 📜LICENSE
 ┃ ┃ ┃ ┃ ┗ 📜README.md
 ┃ ┗ 📂workflows
 ┃ ┃ ┗ 📜ci.yml
 ┣ 📂komla_function
 ┃ ┣ 📜app.py
 ┃ ┗ 📜requirements.txt
 ┣ 📜README.md
 ┗ 📜template.yaml

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lmflyk505a4nnvc7mgpn.PNG)

* Then I pushed contents of `C:\Users\USER_NAME\git-komlalebu-sam` from local to my git [repository](https://github.com/jicoing/git-komlalebu-sam).

>CMD

                 C:\Users\USER_NAME\git-komlalebu-sam>git add .
                 C:\Users\USER_NAME\git-komlalebu-sam>git commit -m master
                 C:\Users\USER_NAME\git-komlalebu-sam>git push origin master


And the source control was setup.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0vobgcej8t0ytnl5d9l4.gif)