/
.travis.yml
44 lines (42 loc) · 1.33 KB
/
.travis.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
sudo: required
language: python
python:
- '3.6'
cache:
directories:
- node_modules
before_install:
- sudo apt-get update
### Installing pre-requisites
install:
- sudo pip install awscli
before_script:
- npm install
script:
- npm run build
### Sending newly generated website to S3 bucket
deploy:
# Control deployment by setting a value for `on`. Setting the `branch`
# option to `master` means Travis will only attempt a deployment on
# builds of your repo's master branch (e.g., after you merge a PR).
on:
branch: master
provider: s3
# You can refer to environment variables from Travis repo settings!
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
# Name of the S3 bucket to which your site should be uploaded.
bucket: $S3_BUCKET
# Prevent Travis from deleting your built site so it can be uploaded.
skip_cleanup: true
# Path to a directory containing your built site.
local_dir: public
# Set the Cache-Control header.
cache_control: "max-age=21600"
### Forcing AWS CloudFront to refresh its cache
before_deploy:
- aws s3 rm s3://$S3_BUCKET --recursive
after_deploy:
# Invalidate every object in the targeted distribution.
- aws configure set preview.cloudfront true
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"