Просмотр исходного кода

Prefix match the branch name to decide what app to build

This allows us to perform test deployments of any of the supported apps.

Refs:
- https://bash.cyberciti.biz/guide/The_case_statement
- https://stackoverflow.com/questions/2172352/in-bash-how-can-i-check-if-a-string-begins-with-some-value
Manav Rathi 1 год назад
Родитель
Сommit
1a9aec23f7
1 измененных файлов с 19 добавлено и 18 удалено
  1. 19 18
      scripts/deploy.sh

+ 19 - 18
scripts/deploy.sh

@@ -2,29 +2,30 @@
 
 
 # This script is run by the Cloudflare Pages integration when deploying the apps
 # This script is run by the Cloudflare Pages integration when deploying the apps
 # in this repository. The app to build and the environment variables to use is
 # in this repository. The app to build and the environment variables to use is
-# decided based on the the value of the CF_PAGES_BRANCH environment variable.
+# decided based on the value of the CF_PAGES_BRANCH environment variable.
+#
+# The Cloudflare Pages build configuration is set to use `out/` as the build
+# output directory, so once we're done building we copy the app specific output
+# to `out/` (symlinking didn't work).
 #
 #
 # Ref: https://developers.cloudflare.com/pages/how-to/build-commands-branches/
 # Ref: https://developers.cloudflare.com/pages/how-to/build-commands-branches/
 
 
 set -o errexit
 set -o errexit
 set -o xtrace
 set -o xtrace
 
 
-# The Cloudflare Pages build configuration is set to use `out/` as the build
-# output directory, so once we're done building we copy the app specific output
-# to `out/` (symlinking didn't work).
-
 rm -rf out
 rm -rf out
 
 
-if test "$CF_PAGES_BRANCH" = "photos-release"; then
-    yarn export:photos
-    cp -R apps/photos/out .
-elif test "$CF_PAGES_BRANCH" = "auth-release"; then
-    yarn export:auth
-    cp -R apps/auth/out .
-elif test "$CF_PAGES_BRANCH" = "accounts-release"; then
-    yarn export:accounts
-    cp -R apps/accounts/out .
-else
-    yarn export:photos
-    cp -R apps/photos/out .
-fi
+case "$CF_PAGES_BRANCH" in
+    accounts-*)
+        yarn export:accounts
+        cp -R apps/accounts/out .
+        ;;
+    auth-*)
+        yarn export:auth
+        cp -R apps/auth/out .
+        ;;
+    *)
+        yarn export:photos
+        cp -R apps/photos/out .
+        ;;
+esac