CI/CD from GitHub to AWS EC2 using GitHub action

Farhan Tanvir
4 min readFeb 27, 2021

I have heard about CI/CD for a long time but never tried it by myself. But I didn’t know how much fun is this. Just some line of code can automate the whole test and deployment thing. Let's see how I achieved this.

I am not going to describe what is CI/CD and GitHub action in book language. There are a lot of resources for that.

According to me CI is checking the application is working or not and CD is deliver the application . Obviously both is in automatic way . But it can do a lots of things. This is just a scratch . GitHub action is a tool which will help us to achieve CI/CD easily and this is also free for certain time limit .

TL;DR

  1. Get public ssh key of EC2 instance
  2. Put the public ssh key in the Git repository’s deploy keys
  3. Get the private key, hostname, and user name of the AWS EC2 instance
  4. Create the .yml file in GitHub to build and deploy the application.

We will use this GitHub repository. But to use this repository we need to install docker and docker-compose in our EC2 instance. Docker can be installed from here and docker-compose from here .

Let's start with the description. First, we need to get the ssh key.

--

--

Farhan Tanvir

Believes in learn by doing . Currently working as a software engineer. Love to share Knowledge. https://twitter.com/FarhanTanvirBD