Automating CI/CD with GitHub Actions and AWS for Seamless Development

Automating CI/CD with GitHub Actions and AWS for Seamless Development

Quick Summary: There perhaps can be other ways through which we can implement the CI/CD pipeline for our robust and rapidly growing application. Wait it sounds complex and being a developer we have a lot more stuff on our plate to do, however, these are the skills nowadays every developer must have knowledge about.

Don’t worry I come up with an easy way to cope with these slightly confusing terms and will surely make it easier for you to implement continuous integration and continuous delivery/continuous deployment with the GitHub Action feature and AWS EC2 (Elastic Computing) instance and Ubuntu machine.


Firstly we should spot the necessity of Continuous Integration and Continuous
delivery/continuous deployment. Suppose we have hosted a website or web application on a hardware machine that is connected to the internet and serves the application over the internet to the end user but as a developer, our team is not sure about the features to achieve our end goal or quality work so we have to make it live each time we implement any features or functionalities so that others can access it over the internet. However here are a few big questions
that arise in front of us which is how we can achieve it? Do we need any physical machine to do this?


The answer is no! We can rent a machine on the cloud which is nothing but a chunk of a huge machine that is partitioned by a software called HyperVisor or Hyper V, with its high reliability and auto-scalable features we can rent an instance of it. Now we can do this with GitHub action so that whenever we push our code to the GitHub repository it will automatically tell our machine that we made any changes to our application so the application has to be re-deploy with the updated
code.

CI/CD pipeline

We are required to perform merely few steps and then we’ll be good to go with it. Let’s implement the CI/CD pipeline using it.
The solution utilizes the following services:

  1. GitHub Actions – Workflow Orchestration tool that will host the Pipeline.
  2. AWS CodeDeploy – AWS service to manage deployment on Amazon EC2 Autoscaling
    Group.
  3. AWS Auto Scaling – AWS Service to help maintain application availability and elasticity by
    automatically adding or removing Amazon EC2 instances.
  4. Amazon EC2 – Destination Compute server for the application deployment.
  5. AWS CloudFormation – AWS infrastructure as code (IaC) service used to spin up the initial
    infrastructure on AWS side.
  6. IAM OIDC identity provider – Federated authentication service to establish trust between
    GitHub and AWS to allow GitHub Actions to deploy on AWS without maintaining AWS
    Secrets and credentials.
    Steps
    The following steps provide a high-level overview of the walkthrough:


    • Login to AWS console and create an ec2 instance

    • Login to ec2 instance

    • Install node js and nginx

    • Push your projects to GitHub

    • Create GitHub action it will create a yml file under
      .github/workflow just edit yml file according to your project

    • Set up GitHub action on ec2 “Not start with sudo” After GitHub configuration run this command

    • Install pm2 and run the backend in the background

    • Add the command in yml script of a project to restart after every commit

    • Config nginx and restart it

    • Now simply restart nginx server with the command below



Published by Darshan Boyat

Keep In Touch With Brain Inventory Sales Executive

Have an idea?
Get in touch, we’d be
happy to hear from you

We are always looking out for new collaborations, whether you are a client who is passionate about a project or a talent who is interested in joining our team, our doors are always open.

locate us

Brain Inventory India (HQ) - 618, Shekhar Central, Palasia Square, A.B Road, Indore, Madhya Pradesh, 452001

India (HQ)

618, Shekhar Central, Palasia Square, A.B Road, Indore, Madhya Pradesh, 452001

+918109561401

Brain Inventory United Kingdom office: SBVS, 8 Roundhay Road, Leeds, UK, LS7 1AB

United Kingdom

Brain Inventory, SBVS, 8 Roundhay Road, Leeds, UK, LS7 1AB

+18008209286

Brain Inventory Canada Office: 44 Main Street East Milton, ONCanada L9T 1N3

Canada

44 Main Street East Milton, ONCanada L9T 1N3

+4166696505

Brain Inventory Jordan Office: 185 Wasfi Al-Tal Street, Ammon Oasis Complex P.O Box 4724 Amman 11953 Jordan

Jordan

185 Wasfi Al-Tal Street, Ammon Oasis Complex P.O Box 4724 Amman 11953 Jordan

+960770781000

Brain Inventory USA Office: 720 Seneca St Ste 107 Seattle, USA 98101

USA

720 Seneca St Ste 107 Seattle, USA 98101

+1(206)6533419

if it's digital,we'll make it.