cdn_upload 921 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. set -e
  3. function upload_into_bucket() {
  4. bucket=$1
  5. # stylesheets
  6. bin/cdn_upload_batch 'text/css' "$bucket" '.css' \
  7. -x '.+(?<!\.css)$' &
  8. # javascript files
  9. bin/cdn_upload_batch 'application/javascript' "$bucket" '.js' \
  10. -x '.+(?<!\.js)$' &
  11. # the rest
  12. bin/cdn_upload_batch '-' "$bucket" '-' \
  13. -x '.+\.(css|js)$' &
  14. wait
  15. }
  16. # Upload to staging CDN if branch is either 'master' or 'staging-master' or main variants
  17. if [[ "$BRANCH_NAME" == "master" || "$BRANCH_NAME" == "staging-master" || "$BRANCH_NAME" == "main" || "$BRANCH_NAME" == "staging-main" ]]; then
  18. tar --directory=/tmp/ -xf build.tar
  19. # delete source maps
  20. find /tmp/public -name '*.js.map' -delete
  21. bin/compress_assets
  22. upload_into_bucket $CDN_STAG
  23. # Only upload to production CDN if branch is
  24. if [[ "$BRANCH_NAME" == "master" || "$BRANCH_NAME" == "main" ]]; then
  25. upload_into_bucket $CDN_PROD
  26. fi
  27. fi