GitHub Actions Certification

Continuous Integration with GitHub Actions

NodeJS Application Overview

Node.js is a powerful, open-source JavaScript runtime built on Chrome’s V8 engine. It enables you to execute JavaScript on the server side, allowing you to use a single language across your entire stack. In this guide, we’ll explore the basics of a minimal Node.js project and prepare for creating a custom GitHub Action workflow.

Platform Support

Node.js runs on Windows, macOS, and most Linux distributions. Ensure you’re using a supported version for compatibility.

Prerequisites

Verify your installed versions:

$ node -v
v18.16.0

$ npm -v
9.8.1

You should have Node.js (v14+) and npm installed.
If not, download them from Node.js Official Site.

Project Structure

A minimal Node.js project typically includes these elements:

ItemDescription
package.jsonMetadata: name, version, dependencies, and custom scripts.
node_modules/Automatically generated by npm install; contains all your packages.
index.jsEntry point for your application—your core business logic.
test.jsUnit tests and integration tests for your functions and endpoints.

Installing Dependencies

Install all required libraries listed in package.json:

npm install

npm install

This command reads package.json and populates the node_modules/ directory with every dependency.

Running Tests

Execute your tests as defined in the test script of package.json:

npm test

A successful run will output results and confirm that all test cases pass.

Starting the Application

Launch the server using the start script:

npm start

By default, the app listens on port 3000. Verify the endpoint:

curl http://localhost:3000/hello
# Expected output: Hello World!

Port Conflict

If port 3000 is in use, modify the port in index.js or set the PORT environment variable before starting.


With your Node.js application up and running, you’re now ready to integrate it into a custom GitHub Action. In the next section, we’ll build a workflow file that automates tests and deployment.

Watch Video

Watch video content

Previous
Project Status Meeting 1