Skip to content

CMS Deployment

Source: omni-cms-composable-cms/infrastructure/lib/pipeline/pipeline-stack.ts, scripts/deploy.sh

The CMS has a dual deployment:

  1. Sanity Studio — Deployed to Sanity’s hosting (<host>.sanity.studio)
  2. Runtime Infrastructure — CDK stack with DAM sync Lambda, SQS queues, Kafka pipe (AWS)

Both are managed by a single CodePipeline per environment.

Diagram
StageTriggerBranchDataset
prodPush to mainmainproduction
preprodPush to mainmainpreprod
stagingGit tagmainstaging
sandboxPush to feature/*feature/*, fix/*, chore/*<branch>_sandbox

For branch feature/cofi-123:

  • Dataset: cofi_123_sandbox
  • Studio host: cofi-123-sandbox-hema-cms
  • Studio URL: https://cofi-123-sandbox-hema-cms.sanity.studio
Terminal window
npm ci
npm run typecheck
npm run lint
npm run validate-schema
npm run cdk:synth
npm run build # Builds Studio
Terminal window
sanity documents validate -y
for file in ./migrations/*.ts; do
sanity migration run "$file" --dataset $DATASET
done
sanity deploy --yes
Terminal window
# Creates sandbox dataset
npx ts-node infrastructure/lib/scripts/create-sandbox.ts
# Deploys Studio + CORS
sanity deploy --yes
sanity cors add $CORS_ORIGIN --credentials

After manual approval:

  1. Undeploys Studio (sanity undeploy)
  2. Deletes CORS origin
  3. Deletes CloudFormation stacks

Branch deletion webhook also triggers cleanup automatically.

Terminal window
aws sso login --profile <profile>
npm run environment:set:sandbox # Creates .env.sandbox
Terminal window
npm run deploy:sandbox
# Or: ./scripts/deploy.sh -s sandbox -p <profile>

The deploy script validates branch name format and blocks non-main branches from deploying to prod/preprod/staging.

Terminal window
npm run deploy:wizard

Interactive wizard for stage selection and deployment.

TaskCommand
Validate schemanpm run validate-schema
Run migrationsnpx sanity migration run migrations/<name>.ts --dataset <dataset>
Build Studionpm run build
Deploy Studio onlySANITY_AUTH_TOKEN=<token> npx sanity deploy --yes
  • Compute: Lambda 8GB (CodeBuild)
  • Image: Amazon Linux 2023, Node 22
  • Packages: @hema from CodeArtifact (hema-prod domain)