How to Build CI/CD Pipeline for Node.js Apps with GitHub Actions

August 19, 2025

You’ve just finished a new feature for your Node.js application. The code works perfectly on your local machine. Now comes the stressful part: deployment. For many, this involves a manual, error-prone ritual of SSH-ing into a server, pulling the latest changes, installing dependencies, and restarting the process manager. One wrong command, and the whole site could go down.

This manual process is a major congestion and a source of unnecessary risk. This is exactly the problem that a modern CI/CD pipeline solves, allowing you to deploy your Node.js app with GitHub Actions in a fully automated, reliable way.

Before we start building, let’s quickly define what CI/CD actually means. It’s a practice, not just a single tool.

  • What is Continuous Integration (CI): This is the practice of developers frequently merging their code changes into a central repository. After each merge, an automated build and test sequence is run. The goal is to detect integration bugs early and maintain a codebase that is always in a working state.
  • What is Continuous Deployment (CD): This is the next step. After the CI phase successfully builds and tests the code, the CD part automatically deploys those changes to a live production environment.

Think of it as an automated assembly line for your code. You write the code, and the CI/CD pipeline takes care of testing it, packaging it, and shipping it to your users, all without manual intervention.

In this step-by-step guide, we’ll build a complete CI/CD pipeline from scratch. We’ll start with a simple Node.js Express app, write a test for it, and then use GitHub Actions to automatically test and deploy it to a live server on every git push.

What You Need to Set Up a CI/CD Pipeline for Node.js with GitHub Actions

To follow along, you’ll just need a few things (Prerequisites), all of which are free to get started with:

  • A GitHub account.
  • Node.js and npm installed on your computer.
  • A free account on Render.com.

Step 1: Building and Testing a Simple Node.js Application

First, we need an application to deploy. Let’s creat e a minimal “Hello World” app using Express, the most popular web framework for Node.js. We will also install Jest for testing and ESLint for code quality checks.

  1. Open your terminal, create a new project directory, and initialize a Node.js project.
    Bash
    mkdir nodejs-cicd-app
    cd nodejs-cicd-app
    npm init -y
    Open your terminal, create a new project directory, and initialize a Node.js project.
  2. Install the necessary dependencies: express for the server, and jest, supertest, and eslint as development dependencies.
    Bash
    npm install express
    npm install –save-dev jest supertest eslintInstall the necessary dependencies: express for the server, and jest, supertest, and eslint as development dependencies.
  3. Now, create a file named index.js and add the following code for your Express server:create a file named index.js and add the following code for your Express server
  4. Next, create a test file named index.test.js to ensure our server works as expected.create a test file named index.test.js to ensure our server works as expected
  5. Finally, open your package.json file and add the test and lint scripts.create a test file named index.test.js to ensure our server works as expected

At this point, you have a complete, testable Node.js application. You can run npm test to verify that your tests pass.

Step 2: Deploy Your Node.js App to Render with GitHub Integration

Now that we have an app, we need a place to host it. For this guide, we’ll be using Render as our deployment platform. It’s an excellent choice for a CI/CD pipeline for Node.js because it offers a generous free tier, automatically handles SSL certificates, and integrates seamlessly with GitHub, making it perfect for personal projects and learning.

  1. Log in to your Render account and click “New +” > “Web Service”.
  2. Connect your GitHub account and select the repository you just created.
  3. On the settings page, give your service a unique name. Render will automatically detect that it’s a Node.js app. Ensure the Start Command is set to npm start.
  4. Choose the Free instance type and click “Create Web Service”.

Render will do an initial deployment, but our goal is to control future deployments via our GitHub Actions pipeline. For that, we need two pieces of information:

  • Your Render Service ID: Go to your new service’s dashboard on Render and find the Service ID in the “Info” section. It will look something like srv-xxxxxxxxxxxxxx.
  • Your Render API Key: Go to your Account Settings > API Keys and create a new key. Copy this key immediately, as Render will not show it to you again.

Keep these two values safe; we’ll need them in the next step.

Step 3: Store API Keys and Secrets in GitHub Securely for CI/CD

A cardinal rule of DevOps is to never commit API keys or other secrets directly into your code. If your repository is public, you’ve just exposed sensitive credentials to the world. The proper way to handle this is with GitHub Secrets.

  1. In your GitHub repository, go to “Settings” > “Secrets and variables” > “Actions”.
  2. Click “New repository secret”.
  3. Create a secret named RENDER_API_KEY and paste the API key you copied from Render.
  4. Create another secret named RENDER_SERVICE_ID and paste your service ID.

Your pipeline can now securely access these values without them ever being visible in your code.

Step 4: Creating the GitHub Actions Workflow for CI/CD

This is the heart of our pipeline. We will create a workflow file that tells GitHub what to do every time we push code.

  1. In your project, create the directory structure .github/workflows/.
  2. Inside that directory, create a new file named deploy.yml.
  3. Paste the following YAML code into deploy.yml:

Creating the GitHub Actions Workflow for CI/CD

This workflow has two separate jobs:

  • build: This job checks out your code, installs dependencies using npm ci (which is faster and more reliable for CI), and runs both your linter and your tests.
  • deploy: This job only runs if the build job completes successfully (thanks to needs: build). It uses curl to send a POST request to the Render API, using the secrets we stored, to trigger a new deployment.

Step 5: Push Code to Trigger CI/CD Workflow and Deploy Node.js App

Commit all your files (index.js, package.json, the .yml file, etc.) and push them to your main branch on GitHub.

Bash
git add .
git commit -m “feat: Add Node.js app and CI/CD workflow”
git push origin main
Push Code to Trigger CI/CD Workflow and Deploy Node.js App

Now, go to the “Actions” tab in your GitHub repository. You will see your pipeline running in real-time. You can click on it to see the build job execute its steps. Once it finishes successfully with a green checkmark, the deploy job will automatically kick off.

Once the deploy job is complete, your latest changes are live on Render. You have successfully automated your Node.js deployment!

CI/CD Pipeline for Node.js: What You’ve Built and What to Explore Next

Congratulations! You have just built a complete, production-ready CI/CD pipeline. You no longer need to deploy manually. Every push to your main branch will now be automatically tested and deployed, giving you the confidence to ship features faster and more reliably.

This is a solid foundation, but a CI/CD pipeline can do so much more. Here are some ideas for what to explore next:

  • Environment-Specific Deployments: Create separate workflows for deploying to staging and production environments.
  • Database Migrations: Add a step to your deployment job to run database migrations before the new code goes live.
  • Comprehensive API Testing: While unit tests are great, a robust pipeline often includes end-to-end [API testing using Postman and Newman] to validate the entire service.

Building reliable DevOps pipelines is at the core of what we do. If you’re looking to scale your infrastructure and implement advanced automation strategies, talk to Varseno’s DevOps experts today.