-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
67 lines (53 loc) · 1.77 KB
/
buildspec.yml
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
version: 0.2
# build env is set to ubuntu v5
env:
shell: bash
phases:
install:
runtime-versions:
nodejs: 20
java: corretto17
pre_build:
commands:
- echo "[Status] pre build started at `date`"
- echo Current directory is `pwd`
- echo STAGE $STAGE
- echo DIST_BUCKET $DIST_BUCKET
- echo FUNCTION_NAME $FUNCTION_NAME
- echo WWW_BUCKET_NAME $WWW_BUCKET_NAME
- echo CLOUDFRONT_DIST_ID $CLOUDFRONT_DIST_ID
# Install software for API build
- echo Installing sbt
- aws s3 cp s3://$DIST_BUCKET/pokerdot/$STAGE/sbt.zip .
- unzip sbt.zip
# Install software for frontend build
- cd frontend
- npm install
- cd ..
- echo "[STATUS] pre build step finished"
build:
commands:
- echo "[Status] Build started at `date`"
# test and package API
- sbt/bin/sbt -no-colors test lambda/Universal/packageBin
# frontend
- cd frontend
- npm run test
- npm run build
- cd ..
- echo "[STATUS] Build finished"
- echo "[STATUS] Deploy started at `date`"
- echo Deploying API to $FUNCTION_NAME
- export DIST_KEY=pokerdot/$STAGE/pokerdot-lambda.zip
- aws s3 cp lambda/target/universal/pokerdot-lambda.zip s3://$DIST_BUCKET/$DIST_KEY
- aws lambda update-function-code --function-name $FUNCTION_NAME --s3-bucket $DIST_BUCKET --s3-key $DIST_KEY
- echo Uploading static site to $WWW_BUCKET_NAME
- cd frontend/dist
- aws s3 sync . s3://$WWW_BUCKET_NAME
- cd ../..
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DIST_ID --paths "/*"
- echo "[STATUS] Deploy finished at `date`"
artifacts:
files:
- lambda/target/universal/pokerdot-lambda.zip
- frontend/dist/**/*