Skip to content
/ cicd-template Public template

Github template repository for CI/CD workflow in Sheares Web

Notifications You must be signed in to change notification settings

ShearesWeb/cicd-template

Repository files navigation

🚀 Project CI/CD Pipeline

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.


🧠 Development Philosophy

🌳 Trunk-Based Development

We follow Trunk-Based Development, where:

  • All developers branch off from main using short-lived feature branches (feat/**, feature/**, JIRA/**).
  • Changes are integrated into main frequently 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.

🧪 Test-Driven Development (TDD)

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

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.

🔁 Sample CI/CD Workflow

  1. 🪄 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 CI workflow to reset the ephemeral environment.
  2. 🧱 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
  3. 🔄 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
  4. 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
  5. 🏷️ 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)
  6. 🚀 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 Files

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

🛠 Technologies

  • Node.js 20.x
  • GitHub Actions for CI/CD
  • npm for dependency management and testing

🔄 Branching Strategy

  • Feature Branches: Follow naming patterns feat/**, feature/**, or JIRA/**.
  • Main Branch: The trunk branch; all releases and integrations occur here.
  • Tags: Use semantic versioning (vX.Y.Z) to trigger production deployments.

📦 Key Scripts (in package.json)

Script Description
npm run lint Static code analysis
npm run test Runs unit tests
npm run build (Optional) Build your app

✅ Contribution Guidelines

  • Write tests first (TDD).
  • Keep feature branches short-lived.
  • Ensure workflows pass before merging PRs.
  • Use meaningful commit messages and tag versions appropriately.

📜 License

This project is licensed under the MIT License.

About

Github template repository for CI/CD workflow in Sheares Web

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published