AGENT SKILL

env-promotion

Design env-promotion (dev → staging → prod) — one artifact promoted, env-specific config injected, gates between stages, rollback path.

License 许可
MIT
最近更新
2026-10-29
Stars
★ 0
Forks
0

01 前言 Front Matter

name
env-promotion
description
Design env-promotion (dev → staging → prod) — one artifact promoted, env-specific config injected, gates between stages, rollback path.

03 SKILL.md 正文

env-promotion

Promote the same artifact through environments rather than rebuilding per env. Pin the gates between stages.

Mode: analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked [TBD] or [VERIFY], never filled in.

When to use

  • A team is moving from "build per env" to "build once, promote".
  • Releases keep regressing because dev/staging differ from prod in ways that aren't tracked.
  • A workflow needs a deploy path before opening prod traffic.

Inputs

  • The environments in order (e.g. dev → staging → prod) and how each is deployed today (required).
  • The artifact type (container image, package, bundle) and where it is stored (registry/repository).
  • The gates the team already has, and who may approve a prod promotion (optional; absent → propose them, marked [VERIFY: approver]).
  • Promotions are side effects: the design shows the exact promote commands; nothing is promoted or deployed without the operator's go-ahead.

Procedure

  1. One artifact, many envs. The same container image / package goes through every stage. Config differs; the binary does not. Promote by immutable digest (image@sha256:…), not by tag — a tag can be re-pointed between stages.
  2. Three default stages:
    • dev — fast feedback. Auto-deploy on merge to main.
    • staging — production-shaped. Production traffic shape (or shadow), production-grade data (sanitized).
    • prod — canary first, then full.
  3. Gate per transition:
    • dev → staging: tests + smoke against deployed dev.
    • staging → prod: error budget healthy, change freeze respected, on-call ack, change record opened (no PII in record).
    • prod canary → prod full: SLO burn rate stays below threshold for canary window; automatic abort otherwise.
  4. Config injection:
    • Per-env config in a single source of truth (a YAML per env in the repo, or a parameter store).
    • No secrets in repo. Secrets injected from a secret manager via env-specific names.
  5. Rollback path named per stage. Usually "redeploy the previous version's image digest". Faster than git revert — and only possible if database migrations are backward-compatible across adjacent versions (expand/contract: polymath-backend:migration-plan); a migration the previous version can't run against is a rollback blocker, so call it out per release.
  6. Observability per stage — same dashboard template, dashboard filterable by env. Alerts route differently per env.

Output

Env promotion: refund-service

Artifact: container image `refund:${git_sha}` pushed once from main;
  promoted by digest (refund@sha256:…), never re-tagged per env.

Stages:
  dev      → auto-deploy on merge to main
              gate: nothing (fast feedback)
  staging  → auto-deploy when dev has been running ≥ 10m with no error
              gate: integration suite pass, traffic-replay smoke pass
  prod     → manual trigger from staging
              gate (canary): 10% traffic for 30m;
                              abort if burn rate > 14× over 1h window
              gate (full):   error rate within 1% of canary baseline
                              for 30m; manual ack required

Config:
  envs/dev.yaml, envs/staging.yaml, envs/prod.yaml in repo.
  Secrets injected at deploy time from AWS Secrets Manager by name.

Rollback:
  deploy prior image tag (we keep last 10). Documented at runbook X.

Observability:
  Single Grafana dashboard with `env` filter. Alerts: dev → silenced,
  staging → #staging-alerts, prod → PagerDuty.

Anti-patterns to avoid

  • Building per env. The binary changes, so the test signal is meaningless.
  • Manual kubectl apply to prod with the local config that "shouldn't differ".
  • Gates that everyone manually skips. If a gate doesn't fire, remove it.
  • No rollback path documented.

04 同仓库更多 Skills