-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·32 lines (25 loc) · 908 Bytes
/
deploy.sh
File metadata and controls
executable file
·32 lines (25 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
set -euo pipefail
BUCKET="ciro-website-static"
DISTRIBUTION_ID="${CLOUDFRONT_DISTRIBUTION_ID:?Set CLOUDFRONT_DISTRIBUTION_ID env var}"
echo "Building..."
npm ci && npm run build
echo "Uploading hashed assets (1yr cache)..."
aws s3 sync dist/assets/ "s3://${BUCKET}/assets/" \
--cache-control "public, max-age=31536000, immutable" \
--delete
echo "Uploading index.html (no cache)..."
aws s3 cp dist/index.html "s3://${BUCKET}/index.html" \
--cache-control "no-cache, no-store, must-revalidate" \
--content-type "text/html"
echo "Uploading remaining files (1hr cache)..."
aws s3 sync dist/ "s3://${BUCKET}/" \
--cache-control "public, max-age=3600" \
--exclude "assets/*" \
--exclude "index.html" \
--delete
echo "Invalidating CloudFront cache..."
aws cloudfront create-invalidation \
--distribution-id "${DISTRIBUTION_ID}" \
--paths "/*"
echo "Deploy complete!"