Mermaid code
flowchart LR
A[Push commit] --> B[Lint and unit tests]
B -->|pass| C[Build image]
B -->|fail| X[Notify author]
C --> D[Deploy to staging]
D --> E[Integration tests]
E -->|pass| F{Approve release?}
E -->|fail| X
F -->|yes| G[Deploy to production]
F -->|no| H[Hold in staging]
G --> I[Smoke tests]
I -->|fail| J[Roll back]
I -->|pass| K[Done]
X --> A Paste this into any tool that renders Mermaid, or into the editor to change the theme and export PNG or SVG. Syntax reference: Flowchart guide.
What this diagram shows
Read this one left to right. Lint and unit tests is the first gate; a failure goes straight to Notify author and loops back to a new push. The Approve release? diamond is the only human step. After Deploy to production, Smoke tests decides between Done and Roll back, so a bad deploy has an explicit exit instead of an implied one.
A flowchart beats a sequence diagram here because the pipeline is about stages and decisions, not about which system talks to which. The horizontal LR layout matches how pipeline UIs draw stages, so the diagram and the tooling look alike.
How to adapt it
- Rename the stage nodes to match your pipeline definition, for example
Build imagetoCompile and packagefor non-container projects. - Add a
Security scannode betweenBuild imageandDeploy to stagingif you run dependency or container scanning. - Remove the
Approve release?diamond and connectIntegration testsdirectly toDeploy to productionfor a continuous deployment setup. - Group stages with
subgraph CI ... endandsubgraph CD ... endto show which part runs on every push and which part runs on merge to main. - Change
flowchart LRtoflowchart TDif you embed the diagram in a narrow document column.
FAQ
How do I show that some stages run in parallel?
Fan out from one node to several, then fan back in. For example C --> D1[Unit tests] and C --> D2[Lint], with both pointing to the next stage. Mermaid draws them side by side.
Why does the failure path point back to the first node?
Because a failed check ends with a new commit, not a retry of the same one. The X --> A edge makes that loop visible. If your pipeline supports re-running a failed job, point the edge at the stage that failed instead.
Can the diamond have more than two outcomes?
Yes. A decision node accepts any number of outgoing edges; label each with -->|text|. Three outcomes such as approve, reject, and defer are common for release gates.