#!/usr/bin/env bash set -euo pipefail cd web npm ci npm run build cd .. BUCKET=$(aws cloudformation describe-stacks \ --stack-name proposal-system-frontend \ --query "Stacks[0].Outputs[?OutputKey=='SiteBucketName'].OutputValue" \ --output text) aws s3 sync web/dist "s3://$BUCKET" --delete DIST_ID=$(aws cloudformation describe-stacks \ --stack-name proposal-system-frontend \ --query "Stacks[0].Outputs[?OutputKey=='DistributionId'].OutputValue" \ --output text) aws cloudfront create-invalidation --distribution-id "$DIST_ID" --paths "/*" # Health check: verify API is reachable API_URL=$(aws cloudformation describe-stacks \ --stack-name proposal-system-compute \ --query "Stacks[0].Outputs[?OutputKey=='ApiEndpoint'].OutputValue" \ --output text) echo "Running post-deploy health check..." HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${API_URL}/api/health" --max-time 10 || true) if [ "$HTTP_STATUS" -eq 200 ]; then echo "Health check passed (HTTP $HTTP_STATUS)" else echo "WARNING: Health check returned HTTP $HTTP_STATUS" >&2 exit 1 fi