-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·62 lines (52 loc) · 1.59 KB
/
build.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
#!/bin/bash
cd "$(dirname "$0")"
set -eu -o pipefail -o posix
if [ "${DEBUG:-x}" == "true" ] || [ "${DEBUG:-x}" == "true" ]; then
set -x
fi
S3_BUCKET="${S3_BUCKET:=aws-codestar-eu-west-1-369205700250-call-api-pipe}"
STACK_NAME="${STACK_NAME:=awscodestar-call-api-lambda}"
echo >&2 "[INFO] Env-Variables:"
echo >&2 " S3_BUCKET=${S3_BUCKET}"
echo >&2 " STACK_NAME=${STACK_NAME}"
function runtests {
>&2 echo "[INFO] run tests"
bash -c 'cd create_user/ && npm test'
}
function package {
>&2 echo "[INFO] packaging node projects"
bash -c 'cd create_user/ && npm install'
bash -c 'cd create_event/ && npm install'
bash -c 'cd list_events/ && npm install'
bash -c 'cd poll/ && npm install'
bash -c 'cd notify/ && npm install'
bash -c 'cd subscribe/ && npm install'
bash -c 'cd register_nfc/ && npm install'
bash -c 'cd get_event_by_nfc/ && npm install'
bash -c 'cd count/ && npm install'
>&2 echo "[INFO] uploading artifacts"
sam package --template-file template.yml \
--output-template-file template-export.yml \
--s3-bucket "$S3_BUCKET"
}
function deploy {
>&2 echo "[INFO] deploying project"
aws cloudformation deploy \
--template-file template-export.yml \
--stack-name "$STACK_NAME" \
--capabilities CAPABILITY_IAM
}
case "${1:-x}" in
setup_build_functions) setup_build_functions ;;
test) runtests ;;
package) package ;;
deploy) deploy ;;
all)
package
runtests
deploy
;;
*) echo >&2 "usage: $0 runtests|package|deploy|all"
exit 1
;;
esac