Skip to content

Rename latest flow to staging for better CI/CD semanticsΒ #5

@warengonzaga

Description

@warengonzaga

🎯 Problem Statement

The current latest-{sha} flow naming is semantically confusing in modern CI/CD pipelines. When code is pushed to the main branch, it generates images tagged as latest-{sha}, but these are not production-ready "latest" releasesβ€”they're pre-production staging images awaiting validation before a manual release.

This naming creates confusion about which images are production-ready versus pre-production staging.

πŸ’‘ Proposed Solution

Rename the latest flow type to staging so that any push to the main branch produces staging-{sha} tagged images instead of latest-{sha}.

Current Behavior

Scenario Flow Type Tag Pattern Semantic Issue
PR (any branch β†’ dev) pr pr-{sha} βœ… Clear
Push to dev dev dev-{sha} βœ… Clear
PR (dev β†’ main) dev dev-{sha} βœ… Clear
PR (any other branch β†’ main) patch patch-{sha} βœ… Clear
Push to main (merge) latest latest-{sha} ⚠️ Confusing
Manual release N/A Handled by separate workflow latest, v1.0.0

Proposed Behavior

Scenario Flow Type Tag Pattern Benefit
PR (any branch β†’ dev) pr pr-{sha} Feature testing
Push to dev dev dev-{sha} Development images
PR (dev β†’ main) dev dev-{sha} Preview staging
PR (any other branch β†’ main) patch patch-{sha} Emergency patch preview
Push to main (any merge) staging staging-{sha} Pre-production validation
Manual release N/A Handled by separate workflow True latest production tag

πŸ”„ Workflow Clarity

Feature Branch --> PR --> dev branch
                           |
                           | (pr-{sha}, dev-{sha})
                           |
                           v
                      PR to main (Preview: dev-{sha})
                           |
Hotfix Branch --> PR to main (Preview: patch-{sha})
                           |
                           v
                      main branch
                           |
                      Auto Build
                           |
                           v
                    staging-{sha} (Pre-production)
                           |
                   Manual Release
                           |
                           v
                  latest + v1.0.x (Production)

πŸ“‹ Implementation Changes Needed

1. Update scripts/detect-build-flow.sh (Lines 188-191)

Current:

# Push to main branch -> Use 'latest' or semantic version
elif [ "$branch" = "$MAIN_BRANCH" ]; then
    flow_type="latest"
    log_success "Flow: Push to main branch (latest)"

Proposed:

# Push to main branch -> staging for pre-production validation
elif [ "$branch" = "$MAIN_BRANCH" ]; then
    flow_type="staging"
    log_success "Flow: Push to main branch (staging)"

2. Update scripts/pr-comment.js Flow Metadata

Add staging flow metadata:

staging: {
  emoji: 'πŸš€',
  title: 'Staging Build',
  description: 'Pre-production validation',
  color: '#ffd700'
}

3. Update Documentation

  • README.md - Update flow types table
  • Examples section - Add staging flow example
  • Flowchart/diagram - Update to show staging flow

βœ… Benefits

  1. Semantic Clarity: staging-{sha} clearly indicates pre-production status
  2. Pipeline Transparency: Developers know these images need validation before release
  3. True latest Tag: Reserved for production releases via manual release workflow
  4. Universal Application: Whether merged from dev or emergency patch, main branch = staging
  5. Industry Standard: Aligns with common CI/CD terminology (dev β†’ staging β†’ production)

πŸ” Use Cases

Use Case 1: Normal Development Flow

feature/api β†’ dev (pr-{sha}, dev-{sha})
           ↓
    PR: dev β†’ main (dev-{sha})
           ↓
   Merge to main (staging-{sha}) ← Pre-production testing
           ↓
  Manual Release (latest, v1.0.4) ← Production

Use Case 2: Emergency Hotfix

fix/security β†’ main (patch-{sha})
           ↓
   Merge to main (staging-{sha}) ← Quick validation
           ↓
  Manual Release (latest, v1.0.5) ← Production

🎯 Expected Outcome

After this change:

  • Development images: pr-{sha}, dev-{sha}, wip-{sha}
  • Pre-production/Staging: staging-{sha} (on main branch)
  • Production: latest, v1.0.x (manual release only)

Clear separation of concerns and no confusion about which images are production-ready.

πŸ“ Notes

  • This is a breaking change that will affect users relying on latest-{sha} tags
  • Consider releasing as a new major version (v2.0.0)
  • Update changelog and migration guide
  • The patch flow should continue to work for any branch (except dev) targeting main, not just branches named "hotfix"

Priority: Enhancement
Impact: Improves clarity and aligns with industry-standard CI/CD semantics

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions