From 66818508bbaa41cb0c35863c2b9854107708dfb1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 12:18:39 +0000 Subject: [PATCH 1/2] Initial plan From f1db165ab68b9ecba36246501d2f6fc44ac58641 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 12:20:36 +0000 Subject: [PATCH 2/2] Add post_build phase with S3 sync and CloudFront invalidation Co-authored-by: ak4dev <92195328+ak4dev@users.noreply.github.com> --- buildspec.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/buildspec.yml b/buildspec.yml index 6791742..9db703d 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -14,6 +14,36 @@ phases: - echo "Building..." - npm run build + post_build: + commands: + - echo "Deploying to S3 and invalidating CloudFront..." + # Sync built assets to S3. Set S3_BUCKET in the CodeBuild environment variables. + - | + if [ -n "$S3_BUCKET" ]; then + echo "Syncing dist/ to s3://$S3_BUCKET" + aws s3 sync dist/ s3://$S3_BUCKET --delete + else + echo "S3_BUCKET not set — skipping S3 sync." + fi + # Invalidate CloudFront so the CDN serves the latest assets immediately. + # Set DISTRIBUTION_ID in the CodeBuild environment variables. + # To invalidate multiple distributions, set EXTRA_DISTRIBUTION_IDS as a + # space-separated list (e.g. "E1EXAMPLE E2EXAMPLE"). + - | + if [ -n "$DISTRIBUTION_ID" ]; then + echo "Creating CloudFront invalidation for distribution $DISTRIBUTION_ID" + aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*" + else + echo "DISTRIBUTION_ID not set — skipping CloudFront invalidation." + fi + - | + if [ -n "$EXTRA_DISTRIBUTION_IDS" ]; then + for id in $EXTRA_DISTRIBUTION_IDS; do + echo "Creating CloudFront invalidation for extra distribution $id" + aws cloudfront create-invalidation --distribution-id $id --paths "/*" + done + fi + # Optional: cache node_modules for much faster rebuilds on subsequent runs cache: paths: