1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Feature/s3 deploy (#243)

* Create deploy.sh

* Update .travis.yml

* Update package.json

* make deploy.sh exec

* Update deploy.sh

* Update .travis.yml

* Update deploy.sh

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
Alex Coseru 2020-11-12 19:20:52 +02:00 committed by GitHub
parent 0c0e15896c
commit 55265cd050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 83 additions and 2 deletions

View File

@ -5,16 +5,26 @@ node_js: node
cache:
npm: true
before_install:
- sudo apt-get -qq update
- sudo apt-get install python3-pip
- sudo -H pip3 install --upgrade pip
- sudo -H pip3 install -U setuptools
before_script:
# - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# - chmod +x ./cc-test-reporter
# - './cc-test-reporter before-build'
script:
# will run `npm ci` automatically here
- npm run lint
# - './cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT'
- npm run build
after_success:
- pip3 install --user awscli
- export PATH=$PATH:$HOME/.local/bin
- npm run deploy
notifications:
email: false

View File

@ -17,7 +17,8 @@
"analyze": "npm run build && source-map-explorer 'public/*.js'",
"storybook": "start-storybook -p 4000 -c .storybook",
"storybook:build": "build-storybook -c .storybook -o public/storybook",
"write:repoMetadata": "node ./scripts/write-repo-metadata > repo-metadata.json"
"write:repoMetadata": "node ./scripts/write-repo-metadata > repo-metadata.json",
"deploy": "./scripts/deploy.sh"
},
"dependencies": {
"@coingecko/cryptoformat": "^0.4.2",

70
scripts/deploy.sh Executable file
View File

@ -0,0 +1,70 @@
#!/usr/bin/env bash
#
# required environment variables:
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
# AWS_DEFAULT_REGION us-east-1
AWS_S3_BUCKET="www-market"
AWS_S3_BUCKET_BETA="www-market-beta"
#
set -e;
function s3sync {
aws s3 sync ./public s3://"$1" \
--include "*" \
--exclude "*.html" \
--exclude "sw.js" \
--exclude "*page-data.json" \
--exclude "chunk-map.json" \
--exclude "sitemap.xml" \
--exclude ".iconstats.json" \
--exclude "humans.txt" \
--exclude "robots.txt" \
--cache-control public,max-age=31536000,immutable \
--delete \
--acl public-read
aws s3 sync ./public s3://"$1" \
--exclude "*" \
--include "*.html" \
--include "sw.js" \
--include "*page-data.json" \
--include "chunk-map.json" \
--include "sitemap.xml" \
--include ".iconstats.json" \
--include "humans.txt" \
--include "robots.txt" \
--cache-control public,max-age=0,must-revalidate \
--delete \
--acl public-read
}
##
## check for pull request against master
##
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "main" ]; then
s3sync $AWS_S3_BUCKET_BETA
##
## check for master push which is no pull request
##
elif [ "$TRAVIS_BRANCH" == "main" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] || [ "$TRAVIS" != true ]; then
s3sync $AWS_S3_BUCKET
echo "---------------------------------------------"
echo " ✓ done deployment "
echo "---------------------------------------------"
exit;
else
echo "---------------------------------------------"
echo " nothing to deploy "
echo "---------------------------------------------"
fi