-
Notifications
You must be signed in to change notification settings - Fork 33
/
deploy.sh
executable file
·51 lines (40 loc) · 1.52 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash -ex
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ${DIR}
### Build Gatsby Static Docs ###
# nvm is provided by the runner, but needs to be setup for this shell env
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm --version
echo "npm and node versions originally provided..."
npm --version
node --version
# use nvm to control the version of node used
nvm install 14.18.1
nvm use 14.18.1
echo "npm and node versions we're going to use..."
npm --version
node --version
# the algolia plugin will create/update/delete indices
export GATSBY_ALGOLIA_APP_ID=$STAGING_GATSBY_ALGOLIA_APP_ID
export GATSBY_ALGOLIA_SEARCH_KEY=$STAGING_GATSBY_ALGOLIA_SEARCH_KEY
export GATSBY_ALGOLIA_WRITE_KEY=$STAGING_GATSBY_ALGOLIA_WRITE_KEY
if [[ $GITHUB_REF == refs/tags/web* ]]; then
export GATSBY_ALGOLIA_APP_ID=$PROD_GATSBY_ALGOLIA_APP_ID
export GATSBY_ALGOLIA_SEARCH_KEY=$PROD_GATSBY_ALGOLIA_SEARCH_KEY
export GATSBY_ALGOLIA_WRITE_KEY=$PROD_GATSBY_ALGOLIA_WRITE_KEY
fi
# build static docs
npm ci
npx gatsby build
### Push Docs to AWS S3 ###
BUCKET=io.appscope.staging
DISTRIBUTION_ID=E2O0IS8RABQ4AT
if [[ $GITHUB_REF == refs/tags/web* ]]; then
BUCKET=io.appscope
DISTRIBUTION_ID=E3CI6UPKUT68NJ
fi
aws s3 rm s3://${BUCKET} --recursive
aws s3 cp ${DIR}/public s3://${BUCKET} --recursive
aws cloudfront create-invalidation --distribution-id=${DISTRIBUTION_ID} --paths '/*'