Git Notes
Deployment workflows define how your code travels from a developer\
Deployment workflows define how your code travels from a developer's machine to production servers where users can access it. In modern software development, deployment is not a manual process — it is automated, repeatable, and integrated directly with your Git workflow. Understanding deployment workflows helps you ship features faster with confidence that nothing will break along the way.
What Is a Deployment Workflow
A deployment workflow is a series of automated steps that takes your committed code, validates it, builds it, and places it on a server. The workflow is typically triggered by Git events — pushing to a branch, merging a pull request, or creating a release tag.
A typical deployment pipeline looks like:
Each stage acts as a quality gate. If tests fail, the pipeline stops. If the build breaks, deployment is halted. This prevents broken code from reaching users.
Types of Deployment Workflows
Continuous Deployment (CD)
Every commit that passes all tests is automatically deployed to production:
Continuous Delivery
Code is automatically prepared for deployment but requires manual approval before going to production. The "Deploy" button is available, but a human decides when to press it.
Environment-Based Deployment
Different branches deploy to different environments:
| feature/* | Preview/Development environment |
| develop | Staging environment |
| main | Production environment |
on:
push:
branches:
- main
- develop
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to staging
if: github.ref == 'refs/heads/develop'
run: deploy-to-staging.sh
- name: Deploy to production
if: github.ref == 'refs/heads/main'
run: deploy-to-production.shBlue-Green Deployment
Blue-green deployment maintains two identical production environments. At any time, one serves live traffic (blue) while the other is idle (green):
| 1. Current traffic | Blue environment (v1.0) |
| 4. Switch traffic | Green becomes active |
| Rollback | Simply switch traffic back to Blue |
This eliminates downtime and provides instant rollback capability.
Rolling Deployment
Updates servers one at a time rather than all at once:
| Server 1 | Update to v2.0 ✓ (serving traffic) |
| Server 2 | Updating... |
| Server 3 | Still on v1.0 (serving traffic) |
| Server 4 | Still on v1.0 (serving traffic) |
If the update fails on any server, stop the rollout and roll back.
Canary Deployment
Route a small percentage of traffic to the new version first:
| 95% traffic | v1.0 (stable) |
| 5% traffic | v2.0 (canary) |
| If healthy | gradually increase to 100% on v2.0 |
| If problems | route all traffic back to v1.0 |
Git-Based Deployment Triggers
Tag-based deployment:
git tag v2.1.0
git push origin v2.1.0
# Triggers production deploymenton:
push:
tags:
- 'v*'Pull request merge deployment:
Deployment Checklist
Before deploying, automated workflows should verify:
- All tests pass (unit, integration, end-to-end)
- Code linting passes
- Build succeeds without errors
- Security scan shows no critical vulnerabilities
- Database migrations are compatible
- Environment variables are configured
- Rollback plan is documented
Rollback Strategies
When a deployment goes wrong:
# Git-based rollback — revert the commit and redeploy
git revert HEAD
git push origin main
# Or deploy a previous known-good tag
git checkout v2.0.9
# Trigger deployment from this tagMonitoring After Deployment
Deployment does not end when code reaches the server. Monitor:
- Error rates (should not spike)
- Response times (should not increase)
- CPU and memory usage
- User-facing functionality (smoke tests)
- Business metrics (conversion rates, signups)
Set up automated alerts that trigger rollback if metrics degrade beyond thresholds.
Key Takeaways
Deployment workflows automate the journey from code commit to production. Choose the strategy that matches your risk tolerance — continuous deployment for fast-moving teams, canary deployments for risk-averse environments, blue-green for zero-downtime requirements. Always include automated testing, monitoring, and rollback capabilities. A good deployment workflow gives you confidence to ship frequently because you know problems will be caught early and reverted quickly.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Deployment Workflows.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Git & GitHub topic.
Search Terms
git-github, git & github, git, github, deployment, workflows, deployment workflows
Related Git & GitHub Topics