From 20aad9ee584497af4f3d9c03943d586617dbf09f Mon Sep 17 00:00:00 2001 From: Alexa Gillman Date: Mon, 5 May 2025 15:31:18 +0000 Subject: [PATCH 1/8] support revision deploys --- .gitignore | 1 + deploy.sh | 35 ++++++++++++++++++++++++++++------- vite.config.ts | 3 +++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index ffa4475..2403ef0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ lerna-debug.log* node_modules dist dist-ssr +preview-dist *.local # Editor directories and files diff --git a/deploy.sh b/deploy.sh index fba43ea..f0814e6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -4,18 +4,30 @@ set -e echo "[--Build: Started--]" -# Clean up the dist directory -echo "Cleaning up the dist directory..." -rm -rf dist +# Check Deploy Type +revision_name=${1:-""} # Use the first argument or default to empty string +echo "Revision name: $revision_name" + +# Set the output directory based on the deploy type +if [ "$revision_name" == "preview" ]; then + output_dir="preview-dist" +else + output_dir="dist" +fi +echo "Output directory: $output_dir" + +# Clean up the output directory +echo "Cleaning up the output directory..." +rm -rf "$output_dir" # Build the frontend echo "Compiling frontend..." npm install -f # force because there is a known mismatch of shadcn and react 19 - https://ui.shadcn.com/docs/react-19 -npm run build +OUTPUT_DIR="$output_dir" npm run build echo "Copying extra files..." -cp /workspaces/proxy.js ./dist/proxy.js -cp ./app.package.json ./dist/package.json +cp /workspaces/proxy.js "$output_dir/proxy.js" +cp ./app.package.json "$output_dir/package.json" echo "[--Build: Complete--]" echo "Executing the deployment upload script" @@ -38,15 +50,24 @@ fi echo "Deploying as ${GITHUB_USER} to ${GITHUB_RUNTIME_PERMANENT_NAME}" +if [ "$revision_name" != "" ]; then + revision_flag="--revision-name $revision_name" +else + revision_flag="" +fi + gh runtime create \ --app ${GITHUB_RUNTIME_PERMANENT_NAME} \ --env "GITHUB_RUNTIME_PERMANENT_NAME=${GITHUB_RUNTIME_PERMANENT_NAME}" \ --secret "GITHUB_TOKEN=${GITHUB_TOKEN}" \ + ${revision_flag} gh runtime deploy \ --app ${GITHUB_RUNTIME_PERMANENT_NAME} \ - --dir dist + --dir "$output_dir" \ + ${revision_flag} +# TODO: Update CLI to get revision app DEPLOYED_URL="$(gh runtime get --app ${GITHUB_RUNTIME_PERMANENT_NAME})" echo "[--URL-App=[https://${DEPLOYED_URL}]--]" diff --git a/vite.config.ts b/vite.config.ts index 1da7c42..1f18d0e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -38,6 +38,9 @@ export default defineConfig({ runtimeTelemetryPlugin(), ...extraPlugins, ], + build: { + outDir: process.env.OUTPUT_DIR || 'dist' + }, define: { // ensure that you give these types in `src/vite-end.d.ts` GITHUB_RUNTIME_PERMANENT_NAME: JSON.stringify(GITHUB_RUNTIME_PERMANENT_NAME), From e2c2c5b07bed3121e0eac6f2d96a8fb41f077c4c Mon Sep 17 00:00:00 2001 From: Alexa Gillman Date: Mon, 5 May 2025 15:36:39 +0000 Subject: [PATCH 2/8] fix casing --- deploy.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/deploy.sh b/deploy.sh index f0814e6..2086744 100755 --- a/deploy.sh +++ b/deploy.sh @@ -5,29 +5,29 @@ set -e echo "[--Build: Started--]" # Check Deploy Type -revision_name=${1:-""} # Use the first argument or default to empty string -echo "Revision name: $revision_name" +REVISION_NAME=${1:-""} # Use the first argument or default to empty string +echo "Revision name: $REVISION_NAME" # Set the output directory based on the deploy type -if [ "$revision_name" == "preview" ]; then - output_dir="preview-dist" +if [ "$REVISION_NAME" != "" ]; then + OUTPUT_DIR="${REVISION_NAME}-dist" else - output_dir="dist" + OUTPUT_DIR="dist" fi -echo "Output directory: $output_dir" +echo "Output directory: $OUTPUT_DIR" # Clean up the output directory echo "Cleaning up the output directory..." -rm -rf "$output_dir" +rm -rf "$OUTPUT_DIR" # Build the frontend echo "Compiling frontend..." npm install -f # force because there is a known mismatch of shadcn and react 19 - https://ui.shadcn.com/docs/react-19 -OUTPUT_DIR="$output_dir" npm run build +OUTPUT_DIR="$OUTPUT_DIR" npm run build echo "Copying extra files..." -cp /workspaces/proxy.js "$output_dir/proxy.js" -cp ./app.package.json "$output_dir/package.json" +cp /workspaces/proxy.js "$OUTPUT_DIR/proxy.js" +cp ./app.package.json "$OUTPUT_DIR/package.json" echo "[--Build: Complete--]" echo "Executing the deployment upload script" @@ -50,8 +50,8 @@ fi echo "Deploying as ${GITHUB_USER} to ${GITHUB_RUNTIME_PERMANENT_NAME}" -if [ "$revision_name" != "" ]; then - revision_flag="--revision-name $revision_name" +if [ "$REVISION_NAME" != "" ]; then + revision_flag="--revision-name $REVISION_NAME" else revision_flag="" fi @@ -64,7 +64,7 @@ gh runtime create \ gh runtime deploy \ --app ${GITHUB_RUNTIME_PERMANENT_NAME} \ - --dir "$output_dir" \ + --dir "$OUTPUT_DIR" \ ${revision_flag} # TODO: Update CLI to get revision app From d6c7c247a32ce1c7121ca2d2d20aedb1f68efd31 Mon Sep 17 00:00:00 2001 From: Alexa Gillman Date: Mon, 5 May 2025 17:33:48 +0000 Subject: [PATCH 3/8] update git ignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2403ef0..2571589 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ lerna-debug.log* node_modules dist dist-ssr -preview-dist +*-dist *.local # Editor directories and files From 8906b5ea9fd2671682bd41b6c40b51c85d0a1d24 Mon Sep 17 00:00:00 2001 From: Alexa Gillman Date: Mon, 5 May 2025 17:44:11 +0000 Subject: [PATCH 4/8] comments --- deploy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 2086744..b5dfb03 100755 --- a/deploy.sh +++ b/deploy.sh @@ -4,11 +4,11 @@ set -e echo "[--Build: Started--]" -# Check Deploy Type +# Check Revision name if exists REVISION_NAME=${1:-""} # Use the first argument or default to empty string echo "Revision name: $REVISION_NAME" -# Set the output directory based on the deploy type +# Set the output directory based on the revision name if provided if [ "$REVISION_NAME" != "" ]; then OUTPUT_DIR="${REVISION_NAME}-dist" else From 871b3617fb03788e9ce103b722e3a026fd0508f4 Mon Sep 17 00:00:00 2001 From: Alexa Gillman Date: Tue, 6 May 2025 14:36:30 +0000 Subject: [PATCH 5/8] update to env variable --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index b5dfb03..2506bef 100755 --- a/deploy.sh +++ b/deploy.sh @@ -5,7 +5,7 @@ set -e echo "[--Build: Started--]" # Check Revision name if exists -REVISION_NAME=${1:-""} # Use the first argument or default to empty string +REVISION_NAME=${REVISION_NAME:-""} # Use the env variable or default to empty string echo "Revision name: $REVISION_NAME" # Set the output directory based on the revision name if provided From d99b063a428380ba7a054258047ed138efb25271 Mon Sep 17 00:00:00 2001 From: Alexa Gillman Date: Tue, 6 May 2025 14:52:37 +0000 Subject: [PATCH 6/8] fix --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 2506bef..503e23c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -68,7 +68,7 @@ gh runtime deploy \ ${revision_flag} # TODO: Update CLI to get revision app -DEPLOYED_URL="$(gh runtime get --app ${GITHUB_RUNTIME_PERMANENT_NAME})" +DEPLOYED_URL="$(gh runtime get --app ${GITHUB_RUNTIME_PERMANENT_NAME} ${revision_flag})" echo "[--URL-App=[https://${DEPLOYED_URL}]--]" echo "[--Deployment: Complete--]" From 504b6c95787232e00bbbb7e7428562548d603984 Mon Sep 17 00:00:00 2001 From: Alexa Gillman Date: Tue, 6 May 2025 14:55:20 +0000 Subject: [PATCH 7/8] remove comment --- deploy.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 503e23c..e0568ca 100755 --- a/deploy.sh +++ b/deploy.sh @@ -67,7 +67,6 @@ gh runtime deploy \ --dir "$OUTPUT_DIR" \ ${revision_flag} -# TODO: Update CLI to get revision app DEPLOYED_URL="$(gh runtime get --app ${GITHUB_RUNTIME_PERMANENT_NAME} ${revision_flag})" echo "[--URL-App=[https://${DEPLOYED_URL}]--]" From 5f503c9afd5438cca9282549ec363cb4e79cacf8 Mon Sep 17 00:00:00 2001 From: Alexa Gillman Date: Wed, 7 May 2025 12:03:38 +0000 Subject: [PATCH 8/8] deploy --- deploy.sh | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/deploy.sh b/deploy.sh index 16d8dd0..8907263 100755 --- a/deploy.sh +++ b/deploy.sh @@ -4,30 +4,18 @@ set -e echo "[--Build: Started--]" -# Check Revision name if exists -REVISION_NAME=${REVISION_NAME:-""} # Use the env variable or default to empty string -echo "Revision name: $REVISION_NAME" - -# Set the output directory based on the revision name if provided -if [ "$REVISION_NAME" != "" ]; then - OUTPUT_DIR="${REVISION_NAME}-dist" -else - OUTPUT_DIR="dist" -fi -echo "Output directory: $OUTPUT_DIR" - -# Clean up the output directory -echo "Cleaning up the output directory..." -rm -rf "$OUTPUT_DIR" +# Clean up the dist directory +echo "Cleaning up the dist directory..." +rm -rf dist # Build the frontend echo "Compiling frontend..." npm install -f # force because there is a known mismatch of shadcn and react 19 - https://ui.shadcn.com/docs/react-19 -OUTPUT_DIR="$OUTPUT_DIR" npm run build +npm run build echo "Copying extra files..." -cp /workspaces/proxy.js "$OUTPUT_DIR/proxy.js" -cp ./app.package.json "$OUTPUT_DIR/package.json" +cp /workspaces/proxy.js ./dist/proxy.js +cp ./app.package.json ./dist/package.json echo "[--Build: Complete--]" echo "Executing the deployment upload script" @@ -50,24 +38,16 @@ fi echo "Deploying as ${GITHUB_USER} to ${GITHUB_RUNTIME_PERMANENT_NAME}" -if [ "$REVISION_NAME" != "" ]; then - revision_flag="--revision-name $REVISION_NAME" -else - revision_flag="" -fi - gh spark create \ --app ${GITHUB_RUNTIME_PERMANENT_NAME} \ --env "GITHUB_RUNTIME_PERMANENT_NAME=${GITHUB_RUNTIME_PERMANENT_NAME}" \ --secret "GITHUB_TOKEN=${GITHUB_TOKEN}" \ - ${revision_flag} gh spark deploy \ --app ${GITHUB_RUNTIME_PERMANENT_NAME} \ - --dir "$OUTPUT_DIR" \ - ${revision_flag} + --dir dist -DEPLOYED_URL="$(gh spark get --app ${GITHUB_RUNTIME_PERMANENT_NAME} ${revision_flag})" +DEPLOYED_URL="$(gh spark get --app ${GITHUB_RUNTIME_PERMANENT_NAME})" echo "[--URL-App=[https://${DEPLOYED_URL}]--]" echo "[--Deployment: Complete--]"