-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·69 lines (57 loc) · 1.83 KB
/
deploy.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
stage=${1:-dev}
install_deps() {
local islayer=false # Flag to track whether we navigated into the nodejs folder
# Check if we're inside a layer directory (layers have a 'nodejs' folder)
if [ -d "nodejs" ]; then
# If we're in a Lambda layer, navigate to the 'nodejs' folder
cd nodejs
islayer=true # Set the flag to true since we navigated into nodejs
fi
if [ "$CI" == "true" ]; then # If we're in a CI system
if [ ! -d "node_modules" ]; then # If we don't have any node_modules (CircleCI cache miss scenario), run npm ci. Otherwise, we're all set, do nothing.
npm ci --legacy-peer-deps
fi
else # We're not in a CI system, let's npm install
npm install --legacy-peer-deps
fi
# If we navigated to the nodejs folder (i.e., for a layer), go back to the root folder
if [ "$islayer" = true ]; then
cd ..
fi
}
deploy() {
pushd services/$1
install_deps
serverless deploy --stage $stage
popd
}
install_deps
services=(
'ui'
'uploads'
'layers/aws-sdk-v2-layer'
'ui-auth' # Moved ui-auth to before app-api to resolve environment variable fetched by serverless in app-api
'app-api'
'email'
'one-stream'
'seatool-sink'
'ui-waf-log-assoc'
'ui-src'
'admin'
)
# Only deploy for higher envs
if [[ "$stage" == "develop" || "$stage" == "master" || "$stage" == "production" ]]; then
services+=('source')
services+=('cross-acct')
fi
set -e
for i in "${services[@]}"; do
deploy $i
done
echo """
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Application endpoint: `./services/output.sh services/ui ApplicationEndpointUrl $stage`
------------------------------------------------------------------------------------------------
"""