Pipelines
CI/CD is a flow, not a place: from where a change starts, through its stages, to where it ends up.
The CityScript
This is all there is to it. Change it in the editor and the city redraws.
%% P · Pipelines
%% Two flows from the same Git server: quick checks on every pull request, and the full release to production.
city 48x32
district staging "Staging" 20,3..33,12
district prod "Production" 20,15..33,22
building git tower at 4,5 "Git server"
floor git.f "Repositories"
room git.repo storage "shop repo"
building registry warehouse at 4,12 "Image registry"
floor registry.f "Images"
room registry.images storage "shop images" port=5000
building preview depot at 37,4 "Preview environment"
floor preview.f "Per pull request"
room preview.web service "pr-482" port=3000
building staging-stack factory in staging "Staging stack"
floor staging-stack.f "Workloads"
room staging-stack.web service "web" port=3000
room staging-stack.db database "postgres" port=5432
building prod-stack factory in prod "Production stack"
floor prod-stack.f "Workloads"
room prod-stack.web service "web" port=3000
room prod-stack.db database "postgres" port=5432
pipeline pr-checks "Pull request checks" git -> [lint] -> [unit-tests] -> [build] -> preview
step git "A developer opens a pull request"
step preview "The change is checked and a preview is built to try"
run lint "npm run lint"
run unit-tests "npm test"
run build "docker build -t shop:pr-$PR ."
pipeline release "Release to production" git -> [build] -> [test] -> [scan] -> [push] -> registry -> [deploy-staging] -> [smoke] -> staging -> [approve] -> [promote] -> prod
step git "A change is merged"
step registry "The tested change is stored as a package"
step staging "It is tried on a copy of the shop"
step prod "A person approves it and it goes live"
run build "docker build -t registry.shop.example/shop:$SHA ."
run test "docker run --rm registry.shop.example/shop:$SHA npm test"
run scan "trivy image --exit-code 1 registry.shop.example/shop:$SHA"
run push "docker push registry.shop.example/shop:$SHA"
run deploy-staging "helm upgrade --install shop ./chart -n staging --set image.tag=$SHA"
run smoke "./scripts/smoke.sh https://staging.shop.example"
run promote "helm upgrade --install shop ./chart -n prod --set image.tag=$SHA"