SuperAPI AI Directory

sync-ci-to-staging-prod

General & other

View repository

Updated 10-16 07:25

About this skill

Sync CI to Staging + Production Skill

This skill will sync the CI environment'sbusiness feature configurationsto the Staging and Production environments in one go. It is suitable for scenarios where new feature configurations that have passed verification on CI need to be rolled out to both Staging and Prod at the same time.

Triggers: "sync ci to staging and prod", "sync configs to all envs", "promote ci config", "sync ci config to staging and prod"

⚠️ Key Principles

  1. Only sync business feature configurations(feature flags, points rates, plan structures, queue definitions, email templates, etc.)
  2. Configurations in the whitelist are never synced(infrastructure connections, Stripe credentials, security switches, etc.)
  3. Staging can be automated,Production requires manual confirmation of ArgoCD sync

Environment difference whitelist (not synced)

The following configuration items are expected to differ across environments andmust be skipped:

Whitelist item CI Staging Prod Reason
database.default.link CI RDS Staging RDS Prod RDS Each environment has its own independent database
redis.default.address k8s-ci k8s-staging k8s-prod Each environment has its own independent MemoryDB
mongodb.default.uri CI DocDB Staging DocDB Prod DocDB Each environment has its own independent DocumentDB
rabbitmq.default.url CI MQ Staging MQ Prod MQ Each environment has its own independent MQ broker
stripe.publishableKey pk_test_* pk_live_* pk_live_* CI uses test keys
stripe.secretKey sk_test_* sk_live_* sk_live_* CI uses test keys
stripe.webhookSecret CI endpoint Staging endpoint Prod endpoint Each environment has its own independent webhook
payment.*.stripePriceId test Price ID live Price ID live Price ID Different Stripe accounts
campaign.sendEmails.redirectEnabled true false false CI security redirect

kubernetes/scripts/compare-configs.py This whitelist is already built in.

Workflow

Step 0: Comprehensive comparison (required)

cd kubernetes

# 查看 3 环境配置差异(自动应用白名单)
python3 scripts/compare-configs.py --diff-only

# 如果有 "需要关注的差异项"(红色),说明有业务配置不一致,需要同步
# 如果只有 "白名单内预期不同"(蓝色),说明已同步完毕

# 查看白名单项详情(可选)
python3 scripts/compare-configs.py --diff-only --show-expected

# 对比其他服务
python3 scripts/compare-configs.py -s simplex-gateway --diff-only
python3 scripts/compare-configs.py -s simplex-router-backend --diff-only

Step 1: Confirm the sync scope

Based on the output of Step 0, confirm which differences need to be synced from CI to Staging/Prod.

Typical syncable items (business features):

  • Email template IDs (resend.welcomeTemplateId, resend.verificationCodeTemplateId , etc.)
  • Email sender (resend.from)
  • Points rate (credit.rates.*, credit.signalRates.*)
  • New user bonus (credit.newUserGrant, credit.newUserGrantWithInvite)
  • Plan structure (payment.plans[] structure, amount, description, concurrency)
  • RabbitMQ queue definitions (rabbitmq.default.queues.* new queue)
  • Worker concurrency (worker.concurrency)

Non-syncable items (whitelist): See the whitelist table above.

Step 2: Perform the sync

Method A: Manual editing (recommended for YAML files under configs/)

For configs/simplex-api/config.yaml and other files, manually add the new CI configuration items to Staging and Prod:

# 打开 3 个文件对比编辑
# CI (源):
#   kubernetes/overlays/aws-ci/configs/simplex-api/config.yaml
# Staging (目标):
#   kubernetes/overlays/aws-staging/configs/simplex-api/config.yaml
# Prod (目标):
#   kubernetes/overlays/aws-prod/configs/simplex-api/config.yaml

Notes:

  • When copying business logic configurations, keep the target file's whitelist values unchanged
  • stripePriceId: Staging/Prod use their own live Price IDs, do not overwrite
  • For newly added pro plans, you need to first create the corresponding Price in the Stripe Live Dashboard, then fill in the ID

Method B: Image tag sync (kustomization.yaml)

# 查看镜像差异
python3 ~/.cursor/skills/sync-ci-to-staging/scripts/sync_images.py --diff

# 同步到 Staging
python3 ~/.cursor/skills/sync-ci-to-staging/scripts/sync_images.py --all --dry-run
python3 ~/.cursor/skills/sync-ci-to-staging/scripts/sync_images.py --all

# 同步到 Prod(需要用 staging-to-prod 脚本)
python3 ~/.cursor/skills/sync-staging-to-prod/scripts/sync_images.py --all --dry-run
python3 ~/.cursor/skills/sync-staging-to-prod/scripts/sync_images.py --all

Step 3: Verify the sync result

cd kubernetes

# 再次运行对比,确认无残留差异
python3 scripts/compare-configs.py --diff-only

# 期望输出:
#   不同: 0  |  白名单(预期不同): N  |  部分缺失: 0

Step 4: Commit and push

cd /path/to/simplex-gitops
git add kubernetes/overlays/aws-staging/ kubernetes/overlays/aws-prod/
git commit -m "chore: sync CI business configs to staging and production

Synced: <列出同步的配置项>
Whitelisted (not synced): infra connections, stripe keys, stripePriceId, campaign.redirectEnabled"
git push

Step 5: Deploy

Staging (can be automated):

argocd app get simplex-aws-staging
argocd app diff simplex-aws-staging
# 如需手动同步:
argocd app sync simplex-aws-staging

Production (must be manual):

# 查看变更(只读,安全)
argocd app get simplex-aws-prod
argocd app diff simplex-aws-prod

# ⛔ 用户明确要求后才执行
argocd app sync simplex-aws-prod

Common Make commands

cd kubernetes

# 对比所有服务配置
make config-diff                               # simplex-api (默认)
make config-diff SVC=simplex-gateway
make config-diff SVC=simplex-router-backend
make list-services                             # 列出所有可对比的服务

# 镜像版本对比
make compare-images                            # 快速 bash 对比
make compare-images-detail                     # 详细 Python 对比

Configuration file mapping

Service CI config path Staging config path Prod config path
simplex-api overlays/aws-ci/configs/simplex-api/config.yaml overlays/aws-staging/configs/simplex-api/config.yaml overlays/aws-prod/configs/simplex-api/config.yaml
simplex-gateway overlays/aws-ci/configs/gateway/config.yaml overlays/aws-staging/configs/gateway/config.yaml overlays/aws-prod/configs/gateway/config.yaml
simplex-router-backend overlays/aws-ci/configs/simplex-router-backend/config-backend.yaml overlays/aws-staging/configs/simplex-router-backend/config-backend.yaml overlays/aws-prod/configs/simplex-router-backend/config-backend.yaml

Service category

Category Service
AI Core anotherme-agent, anotherme-api, anotherme-search, anotherme-worker
Frontend front, front-homepage
Backend simplex-cron, simplex-gateway-api, simplex-gateway-worker
Data data-search-api, crawler
Infrastructure litellm, node-server, simplex-router, simplex-router-backend, simplex-router-fronted

Promotion Path

CI (aws-ci)
  ↓ 本 Skill: 一次同步到 staging + prod
Staging (aws-staging) + Production (aws-prod)

Can also be done step by step:

CI (aws-ci)
  ↓ sync-ci-to-staging skill
Staging (aws-staging)
  ↓ sync-staging-to-prod skill
Production (aws-prod)