-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·36 lines (25 loc) · 860 Bytes
/
deploy.sh
File metadata and controls
executable file
·36 lines (25 loc) · 860 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
33
34
35
36
#!/usr/bin/env bash
# Deploys samsar-docs: rebuilds the site, uploads to S3, and invalidates CloudFront.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"
# Configuration
S3_BUCKET="${S3_BUCKET:-samsar-docs}"
DIST_ID="E2MVTASSD9HUSM"
if ! command -v aws >/dev/null 2>&1; then
echo "aws CLI is required but not found in PATH" >&2
exit 1
fi
if ! command -v npm >/dev/null 2>&1; then
echo "npm is required but not found in PATH" >&2
exit 1
fi
echo "Removing existing build directory..."
rm -rf build
echo "Building site..."
npm run build
echo "Uploading build to s3://${S3_BUCKET}..."
aws s3 sync build/ "s3://${S3_BUCKET}" --delete
echo "Invalidating CloudFront distribution ${DIST_ID}..."
aws cloudfront create-invalidation --distribution-id "${DIST_ID}" --paths "/*"
echo "Deployment complete."