From ffbbbee16676d0377597b941d5ec7a349e79f8d7 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 17:02:30 +0200 Subject: [PATCH] added Makefile and s3sync script --- Makefile | 5 +++++ scripts/s3sync.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Makefile create mode 100644 scripts/s3sync.sh diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..8c84f3b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +build: + sh ./scripts/docker-build.sh + +sync-%: + sh ./scripts/s3sync.sh $* \ No newline at end of file diff --git a/scripts/s3sync.sh b/scripts/s3sync.sh new file mode 100644 index 00000000..44a141a2 --- /dev/null +++ b/scripts/s3sync.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Before first use: +# Install awscli (pip install awscli) +# Configure access credentials (aws configure), region is "eu-central-1" + +function confirm { + read -r -p "Are you sure? [y/N] " response + if [[ $response =~ ^(yes|y)$ ]]; then + echo "let's go!" + else + exit 2 + fi +} + +if [ "x$1" == "x" ]; then + echo "./s3sync.sh stage|beta|wallet [-d]" + exit 1 +fi + +if [ "x$1" == "xstage" ]; then + DIST=../build/beta + BUCKET=stage.mytrezor.com + DISTRIBUTION_ID="E24M0QWO692FQL" + +elif [ "x$1" == "xbeta" ]; then + DIST=../build/beta + BUCKET=beta.mytrezor.com + DISTRIBUTION_ID="E1PONNHWUNCQ9M" + + confirm + +elif [ "x$1" == "xwallet" ]; then + DIST=../build/prod + BUCKET=wallet.mytrezor.com + DISTRIBUTION_ID="EZM01GFTITGVD" + + confirm + +fi + +set -e +cd `dirname $0` + +if [ "x$2" == "x-d" ]; then + aws s3 sync --delete --cache-control 'public, max-age=3600' $DIST s3://$BUCKET/next +else + aws s3 sync --cache-control 'public, max-age=3600' $DIST s3://$BUCKET/next +fi + +aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*' + +echo "DONE" \ No newline at end of file