From 92b5411cb2c021f1228bc6e6e92a1bc97b8605b6 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Wed, 6 Mar 2024 11:44:30 +0530 Subject: [PATCH] Update deployment script --- web/scripts/deploy.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/web/scripts/deploy.sh b/web/scripts/deploy.sh index eb3e26b2df..cbce135b91 100755 --- a/web/scripts/deploy.sh +++ b/web/scripts/deploy.sh @@ -1,8 +1,8 @@ #!/bin/sh # 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 -# decided based on the value of the CF_PAGES_BRANCH environment variable. +# in this repository. The app to build is 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 @@ -12,29 +12,40 @@ # # To test this script locally, run # -# CF_PAGES_BRANCH=foo-bar ./scripts/deploy.sh +# CF_PAGES_BRANCH=deploy/foo ./scripts/deploy.sh # set -o errexit set -o xtrace +if test "$(basename $(pwd))" != "web" +then + echo "ERROR: This script should be run from the web directory" + exit 1 +fi + rm -rf out case "$CF_PAGES_BRANCH" in - accounts-*) + deploy/accounts) yarn build:accounts cp -R apps/accounts/out . ;; - auth-*) + deploy/auth) yarn build:auth cp -R apps/auth/out . ;; - cast-*) + deploy/cast) yarn build:cast cp -R apps/cast/out . ;; - *) + deploy/photos) yarn build:photos cp -R apps/photos/out . ;; + *) + echo "ERROR: We don't know how to build and deploy a branch named $CF_PAGES_BRANCH." + echo " Maybe you forgot to add a new case in web/scripts/deploy.sh" + exit 1 + ;; esac