forked from tryolabs/aws-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.frontend.yml
30 lines (28 loc) · 1001 Bytes
/
buildspec.frontend.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
version: 0.2
env:
variables:
BUCKET_PARAMETER_NAME: "/juanpablo.aws.workshop/prod/codebuild/WEBSITE_BUCKET_NAME"
API_URL_PARAMETER_NAME: "/juanpablo.aws.workshop/prod/frontend/API_URL"
FRONTEND_DIR: "frontend"
BUILD_DIR: "build"
phases:
pre_build:
commands:
- echo "Installing npm dependencies and jq..."
- cd "$FRONTEND_DIR"
- npm install
- apt update
- apt install jq
- pip install --upgrade awscli
build:
commands:
- echo "Build started on `date`"
- echo "Building ..."
- export REACT_APP_API_DOMAIN=`aws ssm get-parameter --name "$API_URL_PARAMETER_NAME" --region us-east-1 | jq -r .Parameter.Value`
- npm run build
post_build:
commands:
- export BUCKET=`aws ssm get-parameter --name "$BUCKET_PARAMETER_NAME" --region us-east-1 | jq -r .Parameter.Value`
- echo "Uploading build to $BUCKET ..."
- aws s3 sync "$BUILD_DIR" "$BUCKET" --delete
- echo "Build completed on `date`"