Building Your First CI/CD Pipeline

 ๐Ÿš€ Step-by-Step Guide: Building Your First CI/CD Pipeline

๐Ÿ”ง Prerequisites

A basic web app or service (Node.js, Python, etc.)


A GitHub account


Familiarity with Git


Docker (optional but useful)


1. Version Control with Git & GitHub

Make sure your project is tracked with Git and pushed to a GitHub repository.


bash

Copy

Edit

git init

git add .

git commit -m "Initial commit"

git remote add origin https://github.com/your-username/your-repo.git

git push -u origin main

2. Define Project Structure

Example: Node.js project structure


bash

Copy

Edit

/my-app

  ├── src/

  ├── tests/

  ├── package.json

  └── .github/workflows/ci.yml

3. Create GitHub Actions Workflow (CI)

In your repo, create .github/workflows/ci.yml:


yaml

Copy

Edit

name: CI Pipeline


on:

  push:

    branches: [ main ]

  pull_request:

    branches: [ main ]


jobs:

  build-and-test:

    runs-on: ubuntu-latest


    steps:

    - name: Checkout code

      uses: actions/checkout@v3


    - name: Set up Node.js

      uses: actions/setup-node@v3

      with:

        node-version: '18'


    - name: Install dependencies

      run: npm install


    - name: Run tests

      run: npm test

This pipeline runs tests automatically on push or PR to the main branch.


4. Add a Simple Deployment Step (CD)

If you're deploying to, say, GitHub Pages or a simple server, append to your workflow:


yaml

Copy

Edit

    - name: Deploy (example)

      run: echo "Deployment logic goes here"

For real deployments, you might use:


Heroku (easy for beginners)


Netlify / Vercel for front-end apps


Docker + SSH to deploy to a cloud VPS


5. Monitor & Iterate

Once your pipeline is running:


Check the Actions tab in GitHub


Watch your workflow in action


Fix failing tests or deployment errors


๐Ÿ”„ Optional Enhancements

Add Linting step with ESLint or Flake8


Use Docker to ensure consistent environments


Add Slack or Email notifications


Split build, test, and deploy into separate jobs


✅ Benefits You'll See

Early bug detection


Faster iteration with automatic tests


Reliable deployments

Learn DevOps Course in Hyderabad

Read More

CI/CD Pipeline

Infrastructure as Code: What and How?

Integrating GitHub Actions into Your Workflow

Git Basics for DevOps Engineers

Visit Our IHub Talent Training Institute in Hyderabad

Get Directions

Comments

Popular posts from this blog

Understanding Snowflake Editions: Standard, Enterprise, Business Critical

Installing Tosca: Step-by-Step Guide for Beginners

Why Data Science Course?