Unsaved
Ready
Loading Monaco Editor...
Preview
Styling
Flowchart
All Software Architecture templates

CI/CD Deployment Pipeline — Mermaid Flowchart

Flowchart showing a complete CI/CD pipeline from code push through testing, staging, and production deployment.

What this diagram shows

This Mermaid flowchart is a left-to-right pipeline. A git push runs lint, typecheck, unit tests, build, and integration tests before a security scan. Vulnerabilities stop the line at Block Deploy. A clean scan builds a Docker image, pushes it to a registry, and deploys staging. End-to-end tests either roll staging back or ask for a manual approval. Approval leads to production, then health checks, which either finish at Live or roll production back.

Use it when a team is agreeing the gates a commit must pass, especially the human approval and the two different rollbacks. Staging rollback and production rollback are separate nodes on purpose. Collapsing them hides which environment failed. The chart is also the right figure for a README section titled How a release ships.

The direction is flowchart LR so the path reads like a timeline from push on the left to Live on the right. Diamonds are the only decisions: the security scan, the e2e result, the approval, and the health check.

Mermaid syntax in this template

Edges that leave a diamond carry the outcome as a label. Straight edges between rectangles are sequential steps with no branch.

  • flowchart LR

    Left to right. A top-down pipeline of this many steps becomes a tall column that is hard to paste into a slide.

  • ScanDep{Security Scan}

    The diamond ID is ScanDep and the label is Security Scan. IDs cannot contain spaces; labels can.

  • E2E -->|Fail| Rollback

    The pipe syntax puts Fail on the edge. Use a short word. Long labels overlap on LR charts.

  • HealthCheck -->|Pass| Done[Live]

    The terminal node is named Done and labeled Live. Naming the ID after the outcome makes later edges easier to attach.

Variations and ways to customize it

Require two approvers

Replace the single Manual Approval diamond with two sequential approvals. If either rejects, both edges should land on Stop so there is one terminal node for a cancelled release.

Approval -->|Approved| SecurityLead{Security Sign-off}
SecurityLead -->|Rejected| Stop[Stop]
SecurityLead -->|Approved| DeployProd[Deploy Production]

Add a canary

Between Deploy Production and Health Checks, insert a canary node and a diamond for error rate. A failed canary should use the existing production rollback node so you do not invent a third rollback.

DeployProd[Deploy Production] --> Canary[Canary 5%]
Canary --> CanaryOk{Error Rate OK?}
CanaryOk -->|No| RollbackProd[Rollback Production]

Mark the critical path

Add a classDef for the nodes that block a release (security scan, e2e, health check) and a second class for optional steps. The linkStyle or class syntax keeps the reading order the same while the color carries severity.

Diagram type

Flowchart

Tags

CI/CDDevOpsdeploymentpipelineDocker
Open in Editor

Frequently asked questions

Where does this Mermaid CI/CD chart roll back?

Twice. E2E failure rolls back staging. Health-check failure rolls back production. Approval rejection and a dirty security scan do not roll anything back; they stop before that environment is updated.

How do I add a migration step to the pipeline flowchart?

Insert it after the staging deploy and before e2e tests, or after production deploy and before health checks, depending on which database you migrate. Give it a rectangle and keep the existing rollback edge on the health check so a bad migration still has an exit.

Should the Docker build sit before or after tests?

In this template the image is built only after unit tests, integration tests, and a clean security scan. Move Docker Build earlier if your integration tests need the image, and point the vulnerability edge at Block Deploy so a bad scan still cannot push the registry.

Can I turn this flowchart into a GitHub Actions view?

The nodes map cleanly onto jobs: lint, typecheck, test, build, scan, deploy-staging, e2e, deploy-prod. The manual approval diamond is the environment protection rule. The chart itself stays Mermaid; Actions will not import the file.

Related templates and guides

All Software Architecture templates