Mirror of static site repo git.pfy.ch/pfych/static
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950#!/bin/bashset -e
STACK_NAME="StaticSiteSiteStack"REGION="ap-southeast-2"PROFILE="dev"
echo "Fetching stack outputs..."OUTPUTS=$(aws cloudformation describe-stacks \ --stack-name "$STACK_NAME" \ --region "$REGION" \ --profile "$PROFILE" \ --query 'Stacks[0].Outputs' \ --output json)
# Extract values from outputsBUCKET_NAME=$(echo "$OUTPUTS" | jq -r '.[] | select(.OutputKey=="BucketName") | .OutputValue')DISTRIBUTION_ID=$(echo "$OUTPUTS" | jq -r '.[] | select(.OutputKey=="CloudFrontDistributionId") | .OutputValue')
if [ -z "$BUCKET_NAME" ] || [ -z "$DISTRIBUTION_ID" ]; then echo "Error: Could not retrieve stack outputs" echo "BucketName: $BUCKET_NAME" echo "DistributionId: $DISTRIBUTION_ID" exit 1fi
echo "Bucket: $BUCKET_NAME"echo "Distribution ID: $DISTRIBUTION_ID"
# Get the .dist directory relative to this scriptDIST_DIR="$(dirname "$0")/../.dist"
if [ ! -d "$DIST_DIR" ]; then echo "Error: .dist directory not found at $DIST_DIR" exit 1fi
echo "Syncing .dist to S3..."aws s3 sync "$DIST_DIR" "s3://$BUCKET_NAME" \ --profile "$PROFILE" \ --delete
echo "Invalidating CloudFront cache..."aws cloudfront create-invalidation \ --distribution-id "$DISTRIBUTION_ID" \ --paths "/*" \ --region "$REGION" \ --profile "$PROFILE"
echo "Done! Site updated and cache invalidated."