@@ -6,17 +6,40 @@ set -euxo pipefail
66export FLUTTER=" ${FLUTTER:- $FLUTTER_STABLE } " ; $FLUTTER --version | grep -i channel
77base=$( dirname " $0 " ) ; cd $base
88
9+ # S3 bucket
10+ bucket=" account.orchid.com"
11+
912echo " Building..."
1013sh 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+
1234echo " 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
1538echo " Updating Cloudfront..."
16- bucket=" account.orchid.com"
1739distribution=$( 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' )
1840AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id " $distribution " --paths " /*" --profile $AWS_PROFILE_ORCHID
1941
2042echo " Deploying widget..."
2143../dapp_widget/deploy-orchid.sh
2244
45+
0 commit comments