This repository serves as a GitHub template repository for implementing robust CI/CD pipelines using GitHub Actions. It supports trunk-based development, ephemeral environments for feature branches, automated testing, and production releases via semantic versioning.
We follow Trunk-Based Development, where:
- All developers branch off from
mainusing short-lived feature branches (feat/**,feature/**,JIRA/**). - Changes are integrated into
mainfrequently to reduce integration risk. - Feature branches are merged quickly via pull requests after passing tests.
- Long-lived branches are avoided in favor of continuous integration and visibility.
We encourage Test-Driven Development, where:
- Tests are written before code implementation.
- Each change must include associated unit/integration tests.
- Code is not merged unless it passes all automated checks.
- This ensures correctness, reliability, and confidence in continuous delivery.
Ephemeral environments are temporary, isolated environments automatically created for each feature branch. These allow developers to develop on a feature without affecting other features.
Benefits:
- Provides a separate environment for each feature development with seed data that mirrors production, ensuring no contention between shared environments.
- Ensures respect for production data and user privacy, as the data in ephemeral environments is isolated.
- Keeps production and pre-production environments pristine, ensuring they are utilized only for dedicated testing, staging, and serving users.
-
🪄 Create Feature Branch
Actions:
- Developer creates a branch from main, e.g.,
feat/user-auth
Workflow:
- An Ephemeral Development Environment is automatically provisioned for the feature branch
- Developers can manually trigger the
Feature Branch CIworkflow to reset the ephemeral environment.
- Developer creates a branch from main, e.g.,
-
🧱 Develop on Feature Branch
Actions:- Developer commits changes to the feature branch
Workflow:
- Linting and unit tests are automatically run on every commit to the feature branch
-
🔄 Create Merge Request (MR) Action:
- Developer opens a pull request (PR) targeting main
Workflow:
- Integration tests are automatically executed in the ephemeral environment to validate the feature integration before allowing merge
-
✅ Merge to Main (after tests & approval) Action
- Maintainers approve the PR
- Developer merges the PR into main
Workflow:
- After merging, the ephemeral environment is automatically destroyed
-
🏷️ Tagging & Deployment of Release Candidate Action:
- Maintainer tags the latest commit as a release candidate (e.g.,
v1.2.3-rc)
Workflow:
- Release candidate is deployed to the pre-production environment
- Functional and E2E tests are conducted on pre-production
- If all tests pass, the release candidate is promoted to an official release with an official tag (e.g.,
v1.2.3)
- Maintainer tags the latest commit as a release candidate (e.g.,
-
🚀 Trigger Production Deployment Action:
- Maintainer manually triggers the production deployment from the official tag Workflow:
- Version is deployed to the production environment
- Functional and E2E tests are conducted on production
| Workflow File | Trigger Condition | Purpose |
|---|---|---|
.github/workflows/ci-feature-branch.yml |
Push or manual trigger from feat/**, feature/**, or JIRA/** branches |
Linting, unit tests, and ephemeral environment creation |
.github/workflows/ci-merge-request.yml |
Pull request to main |
Integration tests before merging |
.github/workflows/ci-post-merge.yml |
PR to main is closed and merged |
Teardown of ephemeral environments |
.github/workflows/preprod-release.yml |
Creation of release candidate tags e.g. v1.0.0-rc |
Deploys preproduction, run post-deploy tests and creation of official versions |
.github/workflows/prd-release.yml |
Manual trigger on official version tags like v1.0.0 |
Deploys production and runs post-deploy tests |
- Node.js 20.x
- GitHub Actions for CI/CD
- npm for dependency management and testing
- Feature Branches: Follow naming patterns
feat/**,feature/**, orJIRA/**. - Main Branch: The trunk branch; all releases and integrations occur here.
- Tags: Use semantic versioning (
vX.Y.Z) to trigger production deployments.
| Script | Description |
|---|---|
npm run lint |
Static code analysis |
npm run test |
Runs unit tests |
npm run build |
(Optional) Build your app |
- Write tests first (TDD).
- Keep feature branches short-lived.
- Ensure workflows pass before merging PRs.
- Use meaningful commit messages and tag versions appropriately.
This project is licensed under the MIT License.