Skip to content

About

A Node/Express web server demonstrating CI/CD with GitHub Actions, Docker, and Render deployment.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ci-cd-tutorial

A small Node/Express example web server used to demonstrate CI/CD with GitHub Actions, Docker, and deployment to Render.


Features / What this repo contains

  • Simple Node/Express server that responds to GET / with an HTML page.
  • Dockerfile to build a container image.
  • Tests (Jest + Supertest) that verify the server returns 200 and contains "web server".
  • GitHub Actions workflows:
    • .github/workflows/ci-pipeline.yml — runs on pull requests to staging and main (install, test, build).
    • .github/workflows/cd-pipeline.yml — runs on pushes to staging and on releases; builds a Docker image, pushes to Docker Hub, and triggers Render deploy hooks.
  • dotenv support for environment variables.

Quick facts (from project files)

  • Name: ci-cd-tutorial (package.json)
  • Author: Saqib Shah
  • License: ISC
  • Main entry: index.js
  • Scripts:
    • npm start — starts the server
    • npm test — runs tests with Jest
  • Key dependencies: express, cors, dotenv
  • Dev dependencies: jest, supertest, @jest/globals, @types/jest

Requirements

  • Node.js (v18 recommended)
  • npm
  • Docker (if using the Dockerfile)
  • For CI/CD: GitHub repository secrets for Docker Hub (DOCKER_USER, DOCKER_PASSWORD) and Render deploy hooks if using the CD workflow

Installation

  1. Clone the repository: git clone https://github.com/SaqibShah-dev/learn-ci-cd.git
  2. Install dependencies: npm install

Running locally

The app reads PORT from environment variables. If not set, it defaults to 5000 in code.

Start: npm start

To run on port 5001 (used in CI and the Docker setup), set the env var: PORT=5001 npm start

The server responds to: GET / — returns a small HTML page (title: "Node Js Web Server" and body containing "Hello world! I'm a Node/Express Js web server...").


Using Docker

Build the image: docker build -t : .

Run the container (example binding port 5001): docker run -e PORT=5001 -p 5001:5001 :

Note: The Dockerfile exposes port 5001. The app defaults to PORT=5000 unless you pass PORT at runtime or via environment.


Tests

This project uses Jest and Supertest.

Run: npm test

Tests are located in __tests__/index.test.js and check:

  • GET / returns HTTP 200
  • Response body contains "web server"

CI / CD

  • CI pipeline (.github/workflows/ci-pipeline.yml):

    • Triggers on pull requests to staging and main.
    • Steps: checkout, npm ci, npm test, and a build step (runs npm run build --if-present).
  • CD pipeline (.github/workflows/cd-pipeline.yml):

    • Triggers on push to staging, workflow_dispatch, and releases.
    • Steps: test, then build image, authenticate to Docker Hub (requires DOCKER_USER and DOCKER_PASSWORD secrets), push the image, and call Render deploy hooks on staging/release using repository secrets RENDER_STAGING_DEPLOY_HOOK and RENDER_PRODUCTION_DEPLOY_HOOK.
    • The workflow tags images using a repository IMAGE variable and ${{ github.sha }}.

Environment variables

  • PORT — port the server listens on (defaults to 5000 if not set)
  • The project uses dotenv (index.js calls config()), so you can place env vars in a .env file during local development.

Contributing

  • Open issues or PRs.
  • Tests should pass (npm test) before merging.
  • For CI/CD changes, add/update workflows under .github/workflows/.

License

ISC


Contact / Links

Repository: https://github.com/SaqibShah-dev/learn-ci-cd Author: Saqib Shah

About

A Node/Express web server demonstrating CI/CD with GitHub Actions, Docker, and Render deployment.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages