Skip to content

Instantly share code, notes, and snippets.

@vitkon
Forked from pranavrajs/travis.yml
Last active December 22, 2017 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitkon/70075c3d68b49b7f511f009867e80aa9 to your computer and use it in GitHub Desktop.
Save vitkon/70075c3d68b49b7f511f009867e80aa9 to your computer and use it in GitHub Desktop.
Travis Config to deploy Frontend to S3 , Invalidate Cache
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