codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🟢

Node.js

49 / 63 topics
49CI/CD Pipelines50Version Control with Git51Collaboration Tools
Tutorials/Node.js/CI/CD Pipelines
🟢Node.js

CI/CD Pipelines

Updated 2026-05-15
10 min read

CI/CD Pipelines

Introduction

Continuous Integration (CI) and Continuous Deployment (CD) are essential practices in modern software development. They help automate the testing and deployment processes, ensuring that your code is always reliable and up-to-date. In this tutorial, we will explore how to set up CI/CD pipelines for Node.js applications using popular tools like GitHub Actions and CircleCI.

Concept

Continuous Integration (CI)

Continuous Integration involves merging all developers' working copies to a shared mainline several times a day. Each integration is verified by an automated build and tests. This helps detect integration errors as quickly as possible, reducing the length of time between integration and deployment.

Continuous Deployment (CD)

Continuous Deployment extends CI by automatically deploying every change that passes the test phase into a production environment. This ensures that your application is always ready to be released at any time.

Examples

We will set up two different CI/CD pipelines: one using GitHub Actions and another using CircleCI.

Setting Up CI/CD with GitHub Actions

GitHub Actions is a powerful automation tool integrated directly into GitHub repositories. It allows you to automate workflows, including building, testing, and deploying your Node.js application.

Step 1: Create a Workflow File

Create a new file named .github/workflows/nodejs.yml in the root of your repository:

YAML
1.github/workflows/nodejs.yml
2name: Node.js CI/CD
3
4on:
5push:
6 branches: [ main ]
7pull_request:
8 branches: [ main ]
9
10jobs:
11build:
12 runs-on: ubuntu-latest
13
14 strategy:
15 matrix:
16 node-version: [14.x, 16.x]
17
18 steps:
19 - uses: actions/checkout@v2
20 - name: Use Node.js ${{ matrix.node-version }}
21 uses: actions/setup-node@v2
22 with:
23 node-version: ${{ matrix.node-version }}
24 - run: npm install
25 - run: npm test
26
27deploy:
28 needs: build
29 runs-on: ubuntu-latest
30 if: github.ref == 'refs/heads/main'
31 steps:
32 - uses: actions/checkout@v2
33 - name: Use Node.js ${{ matrix.node-version }}
34 uses: actions/setup-node@v2
35 with:
36 node-version: ${{ matrix.node-version }}
37 - run: npm install
38 - run: npm run build
39 - name: Deploy to Heroku
40 uses: akhileshns/heroku-deploy@v3.12.12
41 with:
42 heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
43 heroku_app_name: "your-heroku-app-name"
44 heroku_email: "your-email@example.com"`
45}

Step 2: Configure Secrets

In the GitHub repository settings, go to "Secrets and variables" > "Actions" and add your Heroku API key as HEROKU_API_KEY.

Setting Up CI/CD with CircleCI

CircleCI is another popular tool for automating CI/CD pipelines. It provides a flexible configuration file that allows you to define complex workflows.

Step 1: Create a Config File

Create a new file named .circleci/config.yml in the root of your repository:

YAML
1.circleci/config.yml
2version: 2.1
3
4jobs:
5build:
6 docker:
7 - image: cimg/node:14.17.0
8 steps:
9 - checkout
10 - run: npm install
11 - run: npm test
12
13deploy:
14 docker:
15 - image: cimg/node:14.17.0
16 steps:
17 - checkout
18 - run: npm install
19 - run: npm run build
20 - run: |
21 git remote add heroku https://git.heroku.com/your-heroku-app-name.git
22 git push heroku main
23
24workflows:
25version: 2.1
26build-and-deploy:
27 jobs:
28 - build
29 - deploy:
30 requires:
31 - build
32 filters:
33 branches:
34 only: main

Step 2: Configure Environment Variables

In the CircleCI dashboard, go to your project settings and add your Heroku API key as an environment variable.

What's Next?

Now that you have set up CI/CD pipelines for your Node.js application, it's time to focus on version control. In the next section, we will explore how to use Git effectively to manage changes in your codebase.

Happy coding!


PreviousWebhooksNext Version Control with Git

Recommended Gear

WebhooksVersion Control with Git