-
-
Save vitkon/70075c3d68b49b7f511f009867e80aa9 to your computer and use it in GitHub Desktop.
Travis Config to deploy Frontend to S3 , Invalidate 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
sudo: required | |
dist: trusty | |
language: node_js | |
node_js: | |
- "6.9.0" | |
python: | |
- "3.5" | |
cache: | |
- pip | |
- yarn | |
install: | |
# Install any dependencies required for building your site here. | |
# `awscli` is required for invalidation of CloudFront distributions. | |
- pip install awscli | |
before_script: | |
- yarn | |
script: | |
# Build your site (e.g., HTML, CSS, JS) here. | |
yarn run build | |
deploy: | |
- provider: s3 | |
access_key_id: $AWS_ACCESS_KEY_ID | |
secret_access_key: $AWS_SECRET_ACCESS_KEY | |
bucket: $S3_BUCKET_NAME | |
region: $AWS_DEFAULT_REGION | |
skip_cleanup: true | |
local_dir: dist | |
cache_control: "max-age=21600" | |
on: | |
branch: master | |
# Staging Deploy | |
- provider: s3 | |
access_key_id: $AWS_ACCESS_KEY_ID | |
secret_access_key: $AWS_SECRET_ACCESS_KEY | |
bucket: $S3_STAGING_BUCKET_NAME | |
region: $AWS_DEFAULT_REGION | |
skip_cleanup: true | |
local_dir: dist | |
cache_control: "max-age=21600" | |
on: | |
branch: staging | |
after_deploy: | |
- aws configure set preview.cloudfront true | |
- test $TRAVIS_BRANCH = "master" && aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" | |
- test $TRAVIS_BRANCH = "staging" && aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_STAGING_DISTRIBUTION_ID --paths "/*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment