Skip to content

Commit bd44695

Browse files
committed
dapp: tweak deploy script
1 parent 64b9e01 commit bd44695

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

web-ethereum/account_dapp/deploy-orchid.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,40 @@ set -euxo pipefail
66
export FLUTTER="${FLUTTER:-$FLUTTER_STABLE}"; $FLUTTER --version | grep -i channel
77
base=$(dirname "$0"); cd $base
88

9+
# S3 bucket
10+
bucket="account.orchid.com"
11+
912
echo "Building..."
1013
sh build.sh
1114

15+
echo "Creating snapshot..."
16+
# Back up the current contents to a snapshot in the bucket:
17+
# Exclude "snapshots/*" so we don't recursively copy prior snapshots into the new one :)
18+
ts=$(date -u +%Y%m%d-%H%M%S)
19+
echo "Creating in-bucket snapshot at s3://$bucket/snapshots/$ts/ ..."
20+
aws s3 sync s3://$bucket/ s3://$bucket/snapshots/$ts/ \
21+
--exclude "snapshots/*" \
22+
--delete \
23+
--profile $AWS_PROFILE_ORCHID
24+
25+
# Show the new snapshot
26+
echo "Available snapshots:"
27+
aws s3 ls s3://$bucket/snapshots/ --profile $AWS_PROFILE_ORCHID
28+
29+
# To roll back:
30+
# SNAPSHOT_TS="<TIMESTAMP>"
31+
# aws s3 sync s3://$bucket/snapshots/$SNAPSHOT_TS/ s3://$bucket/ --delete --profile $AWS_PROFILE_ORCHID
32+
# Then invalidate CloudFront.
33+
1234
echo "Deploying..."
13-
aws s3 sync --acl public-read --delete ./build/web/ s3://account.orchid.com/ --profile $AWS_PROFILE_ORCHID
35+
# Exclude the snapshots path so --delete does not remove stored snapshots.
36+
aws s3 sync --acl public-read --delete --exclude "snapshots/*" ./build/web/ s3://$bucket/ --profile $AWS_PROFILE_ORCHID
1437

1538
echo "Updating Cloudfront..."
16-
bucket="account.orchid.com"
1739
distribution=$(aws --output json cloudfront list-distributions --profile $AWS_PROFILE_ORCHID | jq -r --arg bucket "$bucket" '.DistributionList.Items[] | select(.Status=="Deployed") | select(.Aliases.Items[] | contains($bucket)) | .Id')
1840
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id "$distribution" --paths "/*" --profile $AWS_PROFILE_ORCHID
1941

2042
echo "Deploying widget..."
2143
../dapp_widget/deploy-orchid.sh
2244

45+

0 commit comments

Comments
 (0)