2019-12-02 07:17:23 -05:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2020-09-28 09:07:35 -04:00
|
|
|
function upload_into_bucket() {
|
|
|
|
bucket=$1
|
|
|
|
|
|
|
|
# stylesheets
|
2021-11-03 07:04:29 -04:00
|
|
|
bin/cdn_upload_batch 'text/css' "$bucket" '.css' \
|
|
|
|
-x '.+(?<!\.css)$' &
|
2020-09-28 09:07:35 -04:00
|
|
|
|
|
|
|
# javascript files
|
2021-11-03 07:04:29 -04:00
|
|
|
bin/cdn_upload_batch 'application/javascript' "$bucket" '.js' \
|
|
|
|
-x '.+(?<!\.js)$' &
|
2020-09-28 09:07:35 -04:00
|
|
|
|
|
|
|
# the rest
|
2021-11-03 07:04:29 -04:00
|
|
|
bin/cdn_upload_batch '-' "$bucket" '-' \
|
|
|
|
-x '.+\.(css|js)$' &
|
2020-09-28 09:07:35 -04:00
|
|
|
|
2021-11-03 07:04:29 -04:00
|
|
|
wait
|
2020-09-28 09:07:35 -04:00
|
|
|
}
|
|
|
|
|
2021-08-03 10:32:13 -04:00
|
|
|
# Upload to staging CDN if branch is either 'master' or 'staging-master' or main variants
|
|
|
|
if [[ "$BRANCH_NAME" == "master" || "$BRANCH_NAME" == "staging-master" || "$BRANCH_NAME" == "main" || "$BRANCH_NAME" == "staging-main" ]]; then
|
2020-05-22 06:34:57 -04:00
|
|
|
tar --directory=/tmp/ -xf build.tar
|
2020-07-02 11:51:38 -04:00
|
|
|
|
|
|
|
# delete source maps
|
|
|
|
find /tmp/public -name '*.js.map' -delete
|
|
|
|
|
2021-11-03 07:04:29 -04:00
|
|
|
bin/compress_assets
|
|
|
|
|
2020-09-28 09:07:35 -04:00
|
|
|
upload_into_bucket $CDN_STAG
|
2020-05-22 06:34:57 -04:00
|
|
|
# Only upload to production CDN if branch is
|
2021-08-03 10:32:13 -04:00
|
|
|
if [[ "$BRANCH_NAME" == "master" || "$BRANCH_NAME" == "main" ]]; then
|
2020-09-28 09:07:35 -04:00
|
|
|
upload_into_bucket $CDN_PROD
|
2019-12-02 07:17:23 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|