gabriel / musehub public
_release_env.sh bash
51 lines 1.8 KB
Raw
sha256:86464e3e1451e0c4629967e7d2812f4d6db4fe412f2931dd5dc28b5e20b4adbe feat(deploy): publish is gated and additive; activation is … Opus 5.5 minor ⚠ breaking 12 days ago
1 # Shared by publish_muse_release.sh and activate_muse_release.sh -- source, do not execute.
2 # Resolves the target environment. No default: the environment is always explicit.
3 #
4 # Sets: ENV INSTANCE_ID BASE_URL PROFILE_ARGS REGION S3_BUCKET
5 # S3 (shared, public-read bucket) always uses the ambient default credentials; only the
6 # per-instance SSM calls need PROFILE_ARGS (production is a separate AWS account).
7
8 REGION="us-east-1"
9 S3_BUCKET="musehub-releases"
10
11 resolve_release_env() {
12 ENV="${1:-}"
13 case "$ENV" in
14 staging)
15 INSTANCE_ID="i-07547cd20bee2dea5"
16 BASE_URL="https://staging.musehub.ai"
17 PROFILE=""
18 ;;
19 production)
20 INSTANCE_ID="i-043aaed71bef11903"
21 BASE_URL="https://musehub.ai"
22 PROFILE="musehub-production"
23 ;;
24 *)
25 return 1
26 ;;
27 esac
28 PROFILE_ARGS=()
29 if [ -n "$PROFILE" ]; then
30 PROFILE_ARGS=(--profile "$PROFILE")
31 fi
32 }
33
34 # ssm_run <comment> <shell command> -- run on the target instance, wait, fail loudly.
35 ssm_run() {
36 local comment="$1" cmd="$2" id status
37 id=$(aws ssm send-command --region "$REGION" ${PROFILE_ARGS[@]+"${PROFILE_ARGS[@]}"} \
38 --instance-ids "$INSTANCE_ID" --document-name "AWS-RunShellScript" \
39 --parameters "commands=[\"$cmd\"]" --comment "$comment" \
40 --timeout-seconds 120 --query "Command.CommandId" --output text) || return 1
41 for _ in $(seq 1 24); do
42 sleep 5
43 status=$(aws ssm get-command-invocation --region "$REGION" ${PROFILE_ARGS[@]+"${PROFILE_ARGS[@]}"} \
44 --command-id "$id" --instance-id "$INSTANCE_ID" --query "Status" --output text 2>/dev/null || echo Pending)
45 case "$status" in
46 Success) return 0 ;;
47 Failed|Cancelled|TimedOut) return 1 ;;
48 esac
49 done
50 return 1
51 }
File History 1 commit
sha256:86464e3e1451e0c4629967e7d2812f4d6db4fe412f2931dd5dc28b5e20b4adbe feat(deploy): publish is gated and additive; activation is … Opus 5.5 minor ⚠ 12 days ago