How to Integrate CircleCI with GitHub Repository?

Integrate CirlceCI with GitHub Repo to deploy the Infrastructure on AWS

ā€¢

Introduction

Embarking on the journey of continuous integration and continuous deployment (CI/CD) is crucial for modern software development. It streamlines the process of building, testing, and deploying code changes, ensuring a faster and more reliable development lifecycle. CircleCI is a robust CI/CD platform that seamlessly integrates with your GitHub repositories, providing automation and efficiency.

This blog post is your guide to kickstarting your CI/CD journey with CircleCI. Weā€™ll walk through the steps to connect your GitHub repository with CircleCI, enabling automated workflows and streamlined development practices.

Prerequisites

Before diving into the integration process, ensure you have the following:

  1. GitHub Account: Make sure you have an active GitHub account. If not, you can sign upĀ here.
  2. CircleCI Account: Sign up for a CircleCI account if you havenā€™t already. You can do this by visiting the official website:Ā CircleCI Signup.
  3. SSH Key Pair: Weā€™ll be using SSH keys to establish a secure connection between CircleCI and your GitHub repository.

Step-by-Step Guide

Go to the CircleCI official website and if you donā€™t have your account on it then do signup.

https://circleci.com/vcs-authorize/

Once you complete the signup process by providing the email address and password, you will get an email that you provided on the CircleCI SignUp process.

Kindly verify your email address and go to the CircleCI official website againĀ https://circleci.com/vcs-authorize/.

Click on the login

Click on theĀ New Project.

You will be landed on the below page

As you observe, in the previous screenshot we got some instructions to connect our Repository of GitHub with CircleCI.

Letā€™s follow this.

Copy the first step command and paste it into your terminal to generate a new ssh key

ssh-keygen -t ed25519 -f ~/.ssh/project_key -C email@example.com

You will see two files that are generated after running the above command.

Copy the content of the public key

cat project_key.pub

Now, we have to paste the public key to the repository that we want to integrate with CircleCI.

Letā€™s take a demo repository and click onĀ Settings.

Click onĀ Deploy keys

Click theĀ Add deploy key

Paste the public key that you have copied in the earlier steps and check theĀ Allow write accessĀ because CircleCI will create some config files like .circleci and config.yml.

Click on theĀ Add key.

Copy the content of the private key.

cat project_key

Go back to the CircleCI page and paste the private key in the dialog box.

Also, I have selected the same repository in which I created the deploy key.

Click onĀ Create Project.

After clicking onĀ Create Project,Ā CircleCI will start to write the configurations and deploy a hello workflow message to show you that your CircleCI integration is successful with GitHub.

Your integration is successful. Now you can modify the config.yml file according to your requirements.

If you observe, CirceCI pushed some changes on circleci-project-setup.

Click on Compare & pull request and click Pull Request.

Once you create the Pull Request and click on Merge pull request.

Once you merge the changes, your repository will have one more folder named .circleci.

Inside the .circleci folder, you will see the config.yml file which is used to create your customized pipeline like you do for other CI/CD tools.

Conclusion

Congratulations! Youā€™ve successfully connected your GitHub repository with CircleCI, laying the foundation for automated CI/CD workflows. With CircleCI, you can now effortlessly manage your development pipeline, ensuring faster and more reliable software delivery. Explore theĀ .circleci/config.ymlĀ file to tailor your workflows and adapt them to your specific project requirements. Happy coding!

Continue Learning

Discover more articles on similar topics