CI/CD for Magento 2: A Staging and Deployment Pipeline Guide
The pipeline that stops deploy-day breakage: what belongs in the build, what staging is for, and how blue-green deploys make rollback boring.

Most Magento breakage we get called about has the same origin story: a change went straight to production. The fix isn't discipline, it's a pipeline - a path to production where the risky steps happen before customers can see them.
The pipeline
Commit
Everything in Git - code, config, composer.lock. If it isn't in the repo, it doesn't exist.
Build
Composer install, DI compile, and static content deploy happen once, in CI - never on the production box.
Stage
The build lands on a staging environment that mirrors production: same PHP, same modules, a scrubbed copy of real data.
Test
Checkout, key catalog pages, and whatever this release touched. Automated where it pays, human where it matters.
Deploy blue-green
The new release comes up alongside the old one and traffic switches over. Zero downtime, no maintenance page.
Rollback
The old release is still there, so rolling back is flipping the switch again - seconds, not a restore job.
What belongs in the build, not on the server
setup:di:compile and static content deployment are the slow, fragile steps - running them on production during a deploy is how stores end up half-broken for twenty minutes. Do them in CI, ship the result as an artifact, and production deploys become file swaps plus setup:upgrade.
What staging is actually for
Not a demo site - a rehearsal. Extension updates, security patches, and version upgrades all get their conflicts found on staging, where finding them costs nothing. A staging environment that drifts from production rehearses the wrong play, so refresh it on a schedule.
We build these pipelines as part of our Magento staging and deployment service - Git workflows, CI/CD, and blue-green deploys with instant rollback. Deploying straight to production is a habit we'll help you break.
✦ FAQ
Does a small Magento store need CI/CD?+–
Can Magento really deploy with zero downtime?+–
What should a staging environment match?+–

Shane Blandford
Founder of Orange Collar Media, a Denver ecommerce agency behind 800+ Magento and Shopify builds. In Magento since version 1.x - building, rescuing, and supporting revenue-critical stores since 2008.
✦ KEEP READING
Related from the Journal.
How to Add Extra Fees to Magento 2 Checkout: Custom Code vs Extension
Two ways to add an extra fee to Magento 2 checkout: a custom totals collector (with working code) or an extension. What each handles, what each breaks.

Magento 2 Surcharges by Payment Method, Shipping Method, and Customer Group
How to add Magento 2 surcharges by payment method, shipping method, or customer group, plus the card-brand and state rules to check before you do.

Charging Handling Fees for Hazmat, Oversized, and Cold-Chain Products in Magento 2
How we set up hazmat, oversized, and cold-chain handling fees in Magento 2 with attribute conditions, plus minimum order and cash on delivery fees.
