GitHub Actions
Continuous Integration with GitHub Actions
Project Status Meeting 1
Overview
In this lesson, we’ll design a GitHub Actions CI/CD pipeline for our Node.js application. We’ll begin by mapping out all nine tasks, then dive into the first four:
- Analyze the Node.js codebase
- Define DevOps requirements
- Identify dependencies and environment variables
- Draft the workflow YAML structure
Once the groundwork is set, we’ll implement jobs for:
- Unit testing
- Code coverage
- Containerization
Let’s get started!
Roadmap: All Nine Tasks
Task | Description |
---|---|
1 | Analyze the Node.js codebase |
2 | Define DevOps requirements (environments, secrets) |
3 | Inventory dependencies and environment variables |
4 | Draft initial workflow YAML structure |
5 | Add unit-test job using Jest |
6 | Integrate code-coverage reporting |
7 | Build and push Docker image |
8 | Deploy to staging environment |
9 | Configure notifications and post-build checks |
Note
Before proceeding, ensure you have:
- Node.js (v16+) installed
- A GitHub repository with your Node.js project
- Basic familiarity with YAML syntax
1. Analyze the Node.js Codebase
Start by exploring your application’s entry point (index.js
or app.js
) and folder structure:
.
├── src/
│ ├── index.js # Application entry
│ ├── routes/ # Express routes
│ └── controllers/ # Route handlers
├── tests/
│ └── app.test.js # Jest test file
├── package.json
└── Dockerfile
- Verify test coverage tools (e.g., Jest).
- Confirm environment variable usage (
dotenv
,process.env
).
2. Define DevOps Requirements
Document your CI/CD goals:
- Which Node.js versions to test?
- Required environment variables (e.g.,
DATABASE_URL
,API_KEY
). - Build matrix (operating systems, Node versions).
Use a .github/workflows/ci.yml
stub:
name: CI Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
3. Inventory Dependencies & Environments
List all production and dev dependencies from package.json
:
{
"dependencies": {
"express": "^4.17.1",
"dotenv": "^10.0.0"
},
"devDependencies": {
"jest": "^29.0.0",
"supertest": "^6.1.3"
}
}
Confirm:
- Lockfile (
package-lock.json
oryarn.lock
) is checked in. - Secrets are added to GitHub under Settings > Secrets and variables > Actions.
4. Draft Initial Workflow Structure
Define job placeholders:
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
setup:
runs-on: ubuntu-latest
needs: analyze
unit-test:
runs-on: ubuntu-latest
needs: setup
build:
runs-on: ubuntu-latest
needs: unit-test
Next steps:
- Install Node.js and cache dependencies.
- Run tests with coverage.
- Build Docker image.
Warning
Always pin action versions (e.g., actions/checkout@v3
) to avoid unexpected breaking changes.
Next Up
In the upcoming session, we’ll:
- Configure Node.js setup and caching
- Add the
unit-test
job using Jest - Generate and upload code coverage reports
Links and References
Watch Video
Watch video content