Skip to content

Instantly share code, notes, and snippets.

@pranavrajs
Last active June 30, 2020 17:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pranavrajs/494f95e8858413118da646d5fec947ed to your computer and use it in GitHub Desktop.
Save pranavrajs/494f95e8858413118da646d5fec947ed 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 "/*"
@jepser
Copy link

jepser commented Jan 31, 2018

It throws an error, with your current configuration.

OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pyasn1'
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
The command "pip install awscli" failed and exited with 2 during .

I ended up using a NPM alternative.

@jplarar
Copy link

jplarar commented Apr 4, 2018

Change:
- pip install awscli
For:
- pip install --user awscli

travis-ci/travis-ci#8449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment