Last active
March 30, 2019 11:43
-
-
Save Sauloxd/12e4ef644dd2030fe439f47e474d2aa3 to your computer and use it in GitHub Desktop.
How to deploy your static asset to S3 using travis CD
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
language: node_js | |
cache: | |
directories: | |
- node_modules | |
script: | |
- npm test | |
- npm run build | |
before_deploy: pip install --user awscli | |
deploy: | |
provider: script | |
script: ~/.local/bin/aws s3 sync build s3://$BUCKET_NAME --region=$BUCKET_REGION --delete && ~/.local/bin/aws s3 cp s3://$BUCKET_NAME/index.html s3://$BUCKET_NAME/index.html --metadata-directive REPLACE --cache-control max-age=0 --region=$BUCKET_REGION | |
acl: public_read | |
bucket: "$BUCKET_NAME" | |
region: "$BUCKET_REGION" | |
local_dir: build | |
skip_cleanup: true | |
on: | |
branch: master | |
env: | |
global: | |
- BUCKET_NAME=saulo.dev | |
- BUCKET_REGION=us-east-1 | |
- secure: [encrypt AWS_ACCESS_KEY_ID] # travis login --pro && travis encrypt AWS_ACCESS_KEY_ID=<<replace-here>> --add --com | |
- secure: [encrypt AWS_SECRET_ACCESS_KEY] # travis login --pro && travis encrypt AWS_SECRET_ACCESS_KEY=<<replace-here>> --add --com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also
~/.local/bin/aws
is only available due tobefore_deploy: pip install --user awscli