forked from sarboc/easi-app-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_static
executable file
·51 lines (46 loc) · 1.53 KB
/
release_static
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
#!/usr/bin/env bash
#
set -eu -o pipefail
case "$APP_ENV" in
"dev")
EASI_URL="https://dev.easi.cms.gov"
export REACT_APP_OKTA_DOMAIN="https://test.idp.idm.cms.gov"
;;
"impl")
EASI_URL="https://impl.easi.cms.gov"
export REACT_APP_OKTA_DOMAIN="https://impl.idp.idm.cms.gov"
;;
"prod")
EASI_URL="https://easi.cms.gov"
export REACT_APP_OKTA_DOMAIN="https://idm.cms.gov"
;;
*)
echo "APP_ENV value not recognized: ${APP_ENV:-unset}"
echo "Allowed values: 'dev', 'impl', 'prod'"
exit 1
;;
esac
export REACT_APP_OKTA_CLIENT_ID="$OKTA_CLIENT_ID"
export REACT_APP_OKTA_SERVER_ID="$OKTA_SERVER_ID"
export REACT_APP_LD_CLIENT_ID="$LD_CLIENT_ID"
export REACT_APP_APP_ENV="$APP_ENV"
export REACT_APP_OKTA_ISSUER="${REACT_APP_OKTA_DOMAIN}/oauth2/${REACT_APP_OKTA_SERVER_ID}"
export REACT_APP_OKTA_REDIRECT_URI="${EASI_URL}/implicit/callback"
export REACT_APP_API_ADDRESS="${EASI_URL}/api/v1"
export REACT_APP_GRAPHQL_ADDRESS="${EASI_URL}/api/graph/query"
# Check if we have any access to the s3 bucket
# Since `s3 ls` returns zero even if the command failed, we assume failure if this command prints anything to stderr
s3_err="$(aws s3 ls "$STATIC_S3_BUCKET" 1>/dev/null 2>&1)"
if [[ -z "$s3_err" ]] ; then
( set -x -u ;
yarn install --frozen-lockfile
yarn run build || exit
aws s3 sync --no-progress --delete build/ s3://"$STATIC_S3_BUCKET"/
)
else
echo "+ aws s3 ls $STATIC_S3_BUCKET"
echo "$s3_err"
echo "--"
echo "Error reading the S3 bucket. Are you authenticated?" 1>&2
exit 1
fi