Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 77ce3de

Browse files
authored
Merge pull request #326 from 0xProject/fix/deploy-clear-cdn-cache
Clear CDN cache upon deployment to live & dogfood
2 parents fdd4ba0 + 0a3a6c6 commit 77ce3de

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
awscli_profile=0xproject

cdn-cache-clear.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
echo Clearing CDN cache...
4+
5+
if [ "$1" = "dogfood" ]; then
6+
id=E16OHMBSODHB04
7+
url=https://dogfood.0xproject.com
8+
elif [ "$1" = "live" ]; then
9+
id=E1PKJDEJRHTC64
10+
url=https://0x.org
11+
else
12+
echo Invalid environment: $1
13+
exit 1
14+
fi
15+
16+
aws cloudfront create-invalidation --distribution-id $id --paths '/*' --profile $(npm config get awscli_profile) || exit $?
17+
sleep 10
18+
curl -sI $url | grep -q 'cache: Miss' || exit $?
19+
curl -sI $url | grep -q 'cache: Hit' || exit $?

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"lint": "tslint --format stylish --project . 'ts/**/*.ts' 'ts/**/*.tsx'",
1818
"fix": "yarn lint --fix",
1919
"pre_push": "yarn tsc --noEmit && yarn lint && yarn test",
20-
"update:tools": "aws s3 sync --delete s3://docs-markdown/ mdx/tools/ --profile 0xproject",
20+
"update:tools": "aws s3 sync --delete s3://docs-markdown/ mdx/tools/ --profile $(npm config get awscli_profile)",
2121
"dev": "npm run update:tools && node --max-old-space-size=16384 ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --mode development --content-base public --https",
22-
"deploy_dogfood": "npm run update:tools && yarn index_docs --environment dogfood && npm run build:prod && aws s3 sync ./public/. s3://dogfood.0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
23-
"deploy_staging": "npm run update:tools && yarn index_docs --environment staging && npm run build:prod && aws s3 sync ./public/. s3://staging-0xproject --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
24-
"deploy_live": "npm run update:tools && yarn index_docs --environment production && DEPLOY_ROLLBAR_SOURCEMAPS=true npm run build:prod && aws s3 sync ./public/. s3://0x.org --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --exclude *.map.js",
22+
"deploy_dogfood": "npm run update:tools && yarn index_docs --environment dogfood && npm run build:prod && aws s3 sync ./public/. s3://dogfood.0xproject.com --profile $(npm config get awscli_profile) --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers && ./cdn-cache-clear.sh dogfood",
23+
"deploy_staging": "npm run update:tools && yarn index_docs --environment staging && npm run build:prod && aws s3 sync ./public/. s3://staging-0xproject --profile $(npm config get awscli_profile) --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
24+
"deploy_live": "npm run update:tools && yarn index_docs --environment production && DEPLOY_ROLLBAR_SOURCEMAPS=true npm run build:prod && aws s3 sync ./public/. s3://0x.org --profile $(npm config get awscli_profile) --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --exclude *.map.js && ./cdn-cache-clear.sh live",
2525
"index_docs": "TS_NODE_PROJECT=./tsconfig-indexing.json node --stack-size=16000 -r ts-node/register scripts/algolia_index.ts"
2626
},
2727
"author": "Fabio Berger",

0 commit comments

Comments
 (0)