Continuous Integration and Continuous Deployment (CI/CD) have become essential parts of modern software development. They help streamline development processes, reduce human errors, and enable faster releases. GitHub serves as a centralized repository for source code, which helps in better collaboration among team members. Combining this with CI/CD enables transparent communication between developers, ensuring everyone knows the latest changes and improvements.

CTO.ai CI/CD pipelines automate the building, testing, and deployment of applications, reducing the time taken for manual processes and accelerating development cycles. This allows teams to identify and fix issues early in development, resulting in quicker releases.

In this blog post, we'll guide you through setting up a CI/CD pipeline on GitHub using CTO.ai.

Prerequisites

Install the Ops CLI

Download the Ops CLI to interact with the CTO.ai platform and its services. With the CLI, you can manage, create, or run operations (automation and workflows) within the platform.

  • Install the CLI with the command npm install -g @cto.ai/ops
  • Once installed, run ops which will display your CLI commands.

Configure your GitHub repository

Next, we’ll configure the GitHub repository to work with your CTO.ai workflows.

  • In your GitHub repository, create a new file named ops.yml in your root directory.
  • In the ops.yml file, add the following content:
version: "1"
pipelines:
 - name: setup-github-repository-workflow-:0.1.0
   description: github repository workflow
   env:
     static:
       - DEBIAN_FRONTEND=noninteractive
       - ORG=<$GITHUB_USERNAME OR GITHUB_ORG>
       - REPO=<$GITHUB_REPO_NAME>
       - REF=main
   events:
     - "github:<github_username -r github_org>/<github_repo>:pull_request.opened"
   jobs:
     - name: github-repository-workflow-build
       description: github repository workflow
       packages:
         - git
       steps:
         - echo "github repo workflow"

The example above is a sample example of configuring CTO.ai pipelines on your GitHub repo to trigger when you open a pull request in your repository. You can configure your Pipelines to suit your application needs.

Replace GITHUB_USERNAME, GITHUB_ORG, AND GITHUB_REPO_NAME with your appropriate GitHub username, organization name, and repository name.

Connect your GitHub repository on CTO.ai

Integrate your GitHub account to get the most out of your activity by installing the CTO.ai GitHub App. When you integrate your repository with the GitHub App, you can measure and analyze various performance metrics related to your application build and deployment process using DORA metrics.

  • Click on Install GitHub App, and select your GitHub account and the GitHub repository to install the GitHub App.

Trigger CI/CD Pipelines on the GitHub repository

Back in your GitHub repository, trigger your CI/CD Pipeline by opening a pull request in your repository. With the pull request open event trigger, you can initiate your pipeline deployment action. Event triggers on CTO.ai are used to automate tasks, enhance collaboration, and improve the overall development workflow of your application.

  • Open a pull request on your sample-app repository on GitHub.
  • In your Pull request console view, you can see your Pipeline has been triggered and running the automated checks. Pipeline checks are the various steps and stages within the CI/CD pipeline that help maintain code quality, ensure correctness, and prevent bugs or other issues from reaching the production environment.

After passing the checks, you can view your pipeline in your CTO.ai pipeline dashboard with the RUN ID, VERSION ID, ACTION trigger, and STATUS.

  • Click on the RUN ID to see the Pipeline logs. CTO.ai pipeline logs are records of events and data generated during the execution of your CI/CD Pipeline. They provide valuable information for your team to monitor, troubleshoot, and optimize the performance of their pipelines. Information obtained from CTO.ai pipeline logs can be build logs, deployment logs, and version control logs.

Supercharge Your CI/CD Pipeline Today

Ready to take your GitHub repositories to the next level? Join countless developers who have streamlined their development workflows with CTO.ai's CI/CD pipeline configuration. Don't let your projects lag behind—get started with CTO.ai and GitHub today and experience the ultimate efficiency and productivity. Click here to request a live demo.