Created
October 25, 2018 01:40
-
-
Save richogreen/73f3041b0f65628c27715e99247a6993 to your computer and use it in GitHub Desktop.
BitBucket Pipelines configuration for Create React App build and deployment to AWS S3 with CloudFront cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a sample build configuration for JavaScript. | |
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples. | |
# Only use spaces to indent your .yml configuration. | |
# ----- | |
# You can specify a custom docker image from Docker Hub as your build environment. | |
image: node:6.9.4 | |
pipelines: | |
default: | |
- step: | |
name: Install dependencies | |
caches: | |
- node | |
script: | |
- npm install | |
- step: | |
name: Test and build | |
caches: | |
- node | |
script: | |
- npm test | |
- npm run build | |
artifacts: | |
- build/** | |
- step: | |
# set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables | |
name: Deploy to S3 | |
deployment: test # set to test, staging or production | |
# trigger: manual # uncomment to have a manual step | |
image: atlassian/pipelines-awscli | |
script: | |
- aws s3 sync --delete ./build s3://$S3_BUCKET_UI | |
- aws s3 cp --cache-control max-age=0 ./build/service-worker.js s3://$S3_BUCKET_UI | |
- step: | |
name: Invalidate cache | |
script: | |
- aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths /* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment