CI and Deployment Helpers
Deploy Target
Pick a Destination
Deployment helpers map a small target name to the destination and caching policy used by the publish command.
Program
Play the script to choose the target and see the destination plan.
deploy_target_plan.sh
Replay: real traced execution (multi-file project)
#!/usr/bin/env bash
target="staging"
if [ "$target" = "prod" ]; then
destination="s3://app-prod"
cache="max-age=300"
else
destination="s3://app-staging"
cache="no-cache"
fi
echo "$target -> $destination ($cache)"
#!/usr/bin/env bash
target="prod"
if [ "$target" = "prod" ]; then
destination="s3://app-prod"
cache="max-age=300"
else
destination="s3://app-staging"
cache="no-cache"
fi
echo "$target -> $destination ($cache)"
target ← staging
3target="staging"4if [ "$target" = "prod" ]; thenvalues this stepstagingtargetif [ "$target" = "prod" ]; then
3target="staging"4if [ "$target" = "prod" ]; then5 destination="s3://app-prod"values this stepstagingtargetdestination ← s3://app-staging
7else8 destination="s3://app-staging"9 cache="no-cache"values this steps3://app-stagingdestinationcache ← no-cache
8 destination="s3://app-staging"9 cache="no-cache"10fivalues this stepno-cachecacheecho "$target -> $destination ($cache)"
10fi11echo "$target -> $destination ($cache)"outputstaging -> s3://app-staging (no-cache)values this stepstagingtargets3://app-stagingdestinationno-cachecache
target ← prod
3target="prod"4if [ "$target" = "prod" ]; thenvalues this stepprodtargetif [ "$target" = "prod" ]; then
3target="prod"4if [ "$target" = "prod" ]; then5 destination="s3://app-prod"values this stepprodtargetdestination ← s3://app-prod
4if [ "$target" = "prod" ]; then5 destination="s3://app-prod"6 cache="max-age=300"values this steps3://app-proddestinationcache ← max-age=300
5 destination="s3://app-prod"6 cache="max-age=300"7elsevalues this stepmax-age=300cacheecho "$target -> $destination ($cache)"
10fi11echo "$target -> $destination ($cache)"outputprod -> s3://app-prod (max-age=300)values this stepprodtargets3://app-proddestinationmax-age=300cache
target
A deployment target is a small name for an environment.
destination
The destination should be derived from the target, not typed repeatedly.
cache policy
Deployment scripts often pair a destination with a cache setting.