-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuildspec.yml
30 lines (30 loc) · 1.36 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
version: 0.1
phases:
install:
commands:
# Install nodejs https://nodejs.org/en/download/package-manager/
- curl -sL https://deb.nodesource.com/setup_8.x | bash -
- apt-get install -y nodejs
# Install yarn natively https://yarnpkg.com/en/docs/install#linux-tab
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- apt-get update
- apt-get install -y yarn
pre_build:
commands:
- yarn
build:
commands:
- CONTENTFUL_SPACE_ID="${CONTENTFUL_SPACE_ID}" CONTENTFUL_ACCESS_TOKEN="${CONTENTFUL_ACCESS_TOKEN}" CONTENTFUL_BLOG_CONTENT_ID="${CONTENTFUL_BLOG_CONTENT_ID}" yarn run build
post_build:
commands:
- |
if [ $CODEBUILD_BUILD_SUCCEEDING = 1 ]
then
aws s3 sync --delete dist/ "s3://${BUCKET_NAME}" --cache-control "max-age=0"
aws s3 cp "s3://${BUCKET_NAME}" "s3://${BUCKET_NAME}" --recursive --exclude "*" --include "*.js" --exclude "sw.js" --cache-control "max-age=31536000" --metadata-directive REPLACE
aws s3 cp "s3://${BUCKET_NAME}" "s3://${BUCKET_NAME}" --recursive --exclude "*" --include "static/*" --cache-control "max-age=31536000" --metadata-directive REPLACE
echo Build success
else
echo Build failed
fi