Continuous Deployment Flow Structures & Pipeline Invocation
Applying continuous deployment flow structures to invoke pipelines (for example, Gitflow, GitHub Flow)
Continuous Deployment Flow Structures & Pipeline Invocation
This guide covers how version control strategies like Gitflow and GitHub Flow act as the primary triggers for automated CI/CD pipelines, specifically within the AWS ecosystem for Machine Learning Engineering.
Learning Objectives
- Differentiate between Gitflow and GitHub Flow branching strategies.
- Understand how repository events (commits, merges, tags) invoke AWS CodePipeline.
- Configure pipeline triggers based on specific branch patterns.
- Map MLOps requirements to appropriate deployment flow structures.
Key Terms & Glossary
- Trunk-Based Development: A version control strategy where developers merge small, frequent updates to a core "main" branch.
- Webhook: An HTTP callback that triggers an action (like starting a pipeline) when a specific event occurs in a repository.
- Artifact: A deployable component (e.g., a Docker image or a serialized ML model file) produced by a build process.
- Feature Branch: A temporary branch used to develop a specific piece of functionality, isolated from the main codebase.
The "Big Idea"
In modern MLOps, the Git repository is the single source of truth. By applying structured flow patterns, we move away from manual deployments. Every code change undergoes automated testing and validation via pipelines, ensuring that only "known-good" models and infrastructure code reach production. The branching strategy you choose dictates the speed and safety of your delivery cycle.
Formula / Concept Box
| Trigger Type | Common Flow Event | AWS Pipeline Invocation |
|---|---|---|
| Source Trigger | git push to a tracked branch | Automatic start via Webhook / EventBridge |
| Periodic Trigger | Scheduled time (Cron) | CloudWatch / EventBridge Rule |
| Manual Trigger | Release Approval | Manual Gate in CodePipeline Stage |
| Artifact Trigger | S3 Upload (Model File) | S3 Event Notification to Pipeline |
Hierarchical Outline
- I. Branching Strategies
- GitHub Flow: Simple, agile, focused on continuous delivery to production.
- Gitflow: Robust, structured, utilizes long-lived branches for different environments (Dev, QA, Prod).
- II. Pipeline Invocation Mechanisms
- Polling: AWS checks the repo periodically (deprecated/inefficient).
- Webhooks: Real-time push notifications from GitHub/GitLab to AWS.
- EventBridge: Centralized event bus for triggering pipelines from AWS native events.
- III. AWS CI/CD Services
- AWS CodeBuild: Compiles code, runs unit tests, and packages models.
- AWS CodeDeploy: Handles the logic of Blue/Green or Canary deployments.
- AWS CodePipeline: The orchestrator that connects the repository to the deployment.
Visual Anchors
The GitHub Flow Lifecycle
CI/CD Pipeline Architecture
\begin{tikzpicture}[node distance=2cm] \draw[thick, rounded corners, fill=blue!10] (0,0) rectangle (2,1) node[pos=0.5] {Source (Git)}; \draw[->, thick] (2,0.5) -- (3,0.5); \draw[thick, rounded corners, fill=green!10] (3,0) rectangle (5,1) node[pos=0.5] {Build (Test)}; \draw[->, thick] (5,0.5) -- (6,0.5); \draw[thick, rounded corners, fill=orange!10] (6,0) rectangle (8,1) node[pos=0.5] {Staging}; \draw[->, thick] (8,0.5) -- (9,0.5); \draw[thick, rounded corners, fill=red!10] (9,0) rectangle (11,1) node[pos=0.5] {Production};
\node at (1, -0.5) {\small Push Trigger};
\node at (7, -0.5) {\small Auto-Deploy};
\node at (10, -0.5) {\small Manual Approval};\end{tikzpicture}
Definition-Example Pairs
- Hotfix Branch: A temporary branch created to fix a critical bug in production immediately.
- Example: An ML model starts returning
nullvalues in production due to a schema change; a developer branches offmain, fixes the logic, and merges it back via an expedited pipeline.
- Example: An ML model starts returning
- Pull Request (PR): A request to merge code changes from one branch to another, usually involving a peer review.
- Example: A Data Scientist completes a new feature engineering script and opens a PR; CodePipeline automatically runs unit tests on the PR code before a human reviews the logic.
Worked Examples
Example 1: Configuring a GitHub Trigger for CodePipeline
Scenario: You want to invoke your training pipeline only when a change is pushed to the models/ directory in the main branch.
- Define Source: Select GitHub (Version 2) as the source provider in AWS CodePipeline.
- Filter Events: Use the "Filter" configuration to specify:
- Branch:
main - File Path:
models/**
- Branch:
- Result: Changes to documentation or UI code in other folders will not trigger the expensive ML training job, saving costs.
Example 2: Implementing a Manual Approval Gate
Scenario: A model is built and tested, but needs a Lead Data Scientist's sign-off before being deployed to the production endpoint.
- Add Stage: In CodePipeline, add a stage between
BuildandDeploy. - Action Type: Select
Manual Approval. - Notification: Configure an SNS topic to email the lead engineer when a model is ready.
- Result: The pipeline pauses; once the engineer clicks "Approve" in the AWS Console, the
CodeDeploystage begins.
Checkpoint Questions
- Which branching strategy is better suited for a team requiring frequent, multiple daily deployments to production?
- In AWS CodePipeline, what is the difference between a "Source" stage and a "Build" stage?
- Why is it recommended to use Webhooks instead of periodic Polling for pipeline triggers?
- What role does Amazon EventBridge play in MLOps pipeline invocation?
Muddy Points & Cross-Refs
- Gitflow Complexity: Students often struggle with the difference between
developandreleasebranches. Tip: Think of 'develop' as the kitchen where everyone is cooking, and 'release' as the staging area where the plate is polished before being served (Master/Production). - Model Registry vs Git: While code lives in Git, models live in the Amazon SageMaker Model Registry. The pipeline usually triggers when the code changes, which then produces a versioned model in the registry.
- Cross-Ref: For more on deployment patterns, see the Deployment Strategies chapter (Blue/Green vs. Canary).
Comparison Tables
| Feature | GitHub Flow | Gitflow |
|---|---|---|
| Primary Branch | main | master and develop |
| Complexity | Low (Simple) | High (Multi-branch) |
| Release Cycle | Continuous (CD) | Scheduled / Versioned |
| Ideal For | Web apps, fast-paced ML teams | Regulated industries, long release cycles |
| Trigger Point | Merge to main | Merge to release/* or master |