deploy.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. # This script is run by the Cloudflare Pages integration when deploying the apps
  3. # in this repository. The app to build is decided based on the value of the
  4. # CF_PAGES_BRANCH environment variable.
  5. #
  6. # The Cloudflare Pages build configuration is set to use `out/` as the build
  7. # output directory, so once we're done building we copy the app specific output
  8. # to `out/` (symlinking didn't work).
  9. #
  10. # Ref: https://developers.cloudflare.com/pages/how-to/build-commands-branches/
  11. #
  12. # To test this script locally, run
  13. #
  14. # CF_PAGES_BRANCH=deploy/foo ./scripts/deploy.sh
  15. #
  16. set -o errexit
  17. set -o xtrace
  18. if test "$(basename $(pwd))" != "web"
  19. then
  20. echo "ERROR: This script should be run from the web directory"
  21. exit 1
  22. fi
  23. rm -rf out
  24. case "$CF_PAGES_BRANCH" in
  25. deploy/accounts)
  26. yarn build:accounts
  27. cp -R apps/accounts/out .
  28. ;;
  29. deploy/auth)
  30. yarn build:auth
  31. cp -R apps/auth/out .
  32. ;;
  33. deploy/cast)
  34. yarn build:cast
  35. cp -R apps/cast/out .
  36. ;;
  37. deploy/photos)
  38. yarn build:photos
  39. cp -R apps/photos/out .
  40. ;;
  41. *)
  42. echo "ERROR: We don't know how to build and deploy a branch named $CF_PAGES_BRANCH."
  43. echo " Maybe you forgot to add a new case in web/scripts/deploy.sh"
  44. exit 1
  45. ;;
  46. esac