Apps Development, Cloud Computing, DevOps

5 Mins Read

CI/CD Pipeline for Web Application Deployment using Heroku and GitHub

Introduction

We now have a new method of deploying to Heroku and incorporating Heroku into other facets of our development processes with GitHub Actions.

A single GitHub Actions workflow could be used to lint our Docker file and package configurations, build and test the package on various environments, compile release notes, and upload our app to Heroku.

What does CI/CD mean?

A build is produced by continuous integration for freshly pushed code to the repository. Developers regularly merge their code changes into a central repository, after which automatic builds and tests are executed. Continuous deployment is the process of constantly deploying code to production. Continuous deployment can lead to safer deployments because you make minor changes to the application with each deployment. As a result, changes to an application can be deployed into production more rapidly than manually.

Any application bugs can be swiftly identified and the deployment responsible identified. When we use continuous deployment, we don’t have to wait for someone else to click a button and transmit changes to production. Furthermore, we’re not bundling all our updates into a single version. Instead, if our automated checks are successful, we use continuous deployment to deploy every update we submit to our main branch.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Why use Heroku and GitHub Actions?

The simplest way of deployment is through GitHub Actions and Heroku, which is why the platform was selected. When using Heroku, no knowledge of server setup, network administration, or database tuning is required. Heroku removes obstacles so developers can concentrate on making apps. Heroku is a pay-per-second product, and the user can choose the subscription plan that best suits their requirements. Heroku is incredibly flexible. Just scale your application’s dynos if a user’s application has a lot of HTTP traffic. The continuous integration and delivery platform that GitHub Actions offers enables you to automate your build, test, and deployment pipelines. It also supports numerous coding languages, enabling a wide range of applications to be deployed.

Uses of GitHub Actions:

You can create unique workflows in reaction to GitHub events using GitHub Actions. An issue could start a bot answer. A push could start Continuous Integration (CI), a merged pull request could start a deployment, etc. Jobs form the basis of workflows. Runners carry out these activities in a simulated setting. Individual steps, which can be scripts or activities executed on the runner, make up jobs. GitHub Marketplace, the Docker registry, or directly in your repository are all options for including actions, which are modular workflow units that can be made in Docker containers.

Steps for Continuous Integration

  1. Go to your project’s Actions tab in the GitHub folder by selecting it from the toolbar.
  2. Select the updated workflow alternative. If you create an Action for the first time, you can skip step 2 and go straight to step 3.
  3. From the available templates for continuous integration processes, select the Node.js template.
  4. For your account, GitHub will generate a node.js.yml file. The new file will be committed to your repository after you select the start to commit choice. This completes the setup for continuous integration and initiates workflow execution.
  5. Refer to the below images for guidance.

step1

Click on Start Commit

step1b

Here is the image after committing the yaml file.

step1c

Steps for Continuous Delivery

  1. From your Heroku homepage, select Account Settings.
  2. Click Reveal in the API Key portion of the page.
  3. Make a copy of the exposed API Key.
  4. Return to your GitHub project and select the Settings menu item in the toolbar.
  5. From the sidebar, select Secrets, then create a new repository secret.
  6. A name and a value must be entered to create a new repository secret. You can enter the API Key you copied from Heroku into the value field and use the name field’s prefix HEROKU_API_KEY.
  7. Deploying the code to Heroku is the last stage after creating the continuous delivery pipeline.
  8. Refer to the below images for guidance.

step2

Open the repo in GitHub as shown below

step2b

After adding key and Value

step2c

Clone the repo in the local system:

C:\Users\PattanImraan\Desktop>git clone https://github.com/pattanImraan/testrepo.git

Cloning into ‘testrepo’…

remote: Enumerating objects: 5, done.

remote: Counting objects: 100% (5/5), done.

remote: Compressing objects: 100% (2/2), done.

remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0

Receiving objects: 100% (5/5), done.

Install Heroku CLI using npm

After installing CLI, enter the below cmd in the command prompt:

Utilize the Heroku CLI to deploy your code to Heroku. On your local computer, you must first run the Heroku CLI. Once installed, the following commands can be used to deploy your code to Heroku.

This will open the browser, and after entering successful credentials, we can push the code to heroku

After manually deploying the app, you must make a few adjustments to the current node.js.yml file to ensure that the modifications are immediately deployed to Heroku when you send them to the main branch of your GitHub repository.

The deploy is in charge of automatically deploying the changes you submit to your GitHub repository and is given instructions along these lines.

step2d

Conclusion

Any code you push to the branch of your GitHub repository linked to the deployment will immediately be deployed and reflected on your web application once the continuous deployment pipeline is completely configured. Each deployment has its area in your GitHub repository’s Actions section. While deploying this program, we got hands-on practice setting up the environment, pipelines, and branches. This enabled us to deploy our application effectively and fix any issues. In summary, automating deployment is advantageous because it releases without error and as soon as a commit is merged, enabling application updates to be live in production in a flash.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is an official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft Gold Partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding Heroku, GitHub and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. How long is Heroku free to use?

ANS: – A foundation of 550 free dyno hours is offered to personal accounts each month. All accounts verified with a credit card are eligible for an extra 450 free dyno hours, for a total of 1000 hours per month.

2. Is Heroku just for online apps?

ANS: – Heroku is an app and data platform that offers a safe, scalable database-as-a-service and a tons of developer tools like database followers, forking, data clips, and automatic health checks.

WRITTEN BY Imraan Pattan

Imraan is a Software Developer working with CloudThat Technologies. He has worked on Python Projects using the Flask framework. He is interested in participating in competitive programming challenges and Hackathons. He loves programming and likes to explore different functionalities for creating backend applications.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!