From db2d3e7d09e8f7319719e8ef4506ba0ee204a00c Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sat, 6 Sep 2025 09:18:30 -0600 Subject: [PATCH] update deploy script --- .github/workflows/deploy-web-staging.yml | 116 +++++++++++++++++++++++ .gitignore | 1 - apps/web/.gitignore | 1 - apps/web/nitro.config.js | 43 ++++----- apps/web/package.json | 2 - apps/web/wrangler.example.jsonc | 47 --------- apps/web/wrangler.jsonc | 65 +++++++++++++ 7 files changed, 201 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/deploy-web-staging.yml delete mode 100644 apps/web/wrangler.example.jsonc create mode 100644 apps/web/wrangler.jsonc diff --git a/.github/workflows/deploy-web-staging.yml b/.github/workflows/deploy-web-staging.yml new file mode 100644 index 000000000..6e90a79b2 --- /dev/null +++ b/.github/workflows/deploy-web-staging.yml @@ -0,0 +1,116 @@ +name: Deploy Web to Staging + +on: + push: + branches: + - staging + paths: + - "apps/web/**" + workflow_dispatch: + +# Cancel in-progress deployments when a new commit is pushed +concurrency: + group: deploy-web-staging-${{ github.ref }} + cancel-in-progress: true + +env: + CI: true + +jobs: + deploy: + name: Deploy to Staging + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 30 + environment: staging + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 9.15.0 + + - name: Setup Node.js + uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: 'pnpm' + + - name: Cache node_modules + uses: actions/cache@v4 + with: + path: | + node_modules + apps/web/node_modules + key: pnpm-web-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/web/package.json') }} + restore-keys: | + pnpm-web-${{ hashFiles('pnpm-lock.yaml') }}- + pnpm-web- + + - name: Cache Turbo + uses: actions/cache@v4 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}- + turbo-${{ github.job }}- + + - name: Install dependencies + run: pnpm install --frozen-lockfile --filter=@buster-app/web + + - name: Build required packages + run: pnpm build --filter=@buster-app/web + env: + NODE_ENV: production + NODE_OPTIONS: --max-old-space-size=8192 + TURBO_CACHE_DIR: .turbo + TURBO_TELEMETRY_DISABLED: 1 + + - name: Deploy to Cloudflare Workers + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: deploy .output/server/index.mjs --env staging --assets .output/public + workingDirectory: apps/web + env: + NODE_ENV: production + + - name: Get commit info + id: commit + run: | + echo "sha_short=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT + echo "sha_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Create deployment summary + if: success() + run: | + SHA="${{ steps.commit.outputs.sha_short }}" + + echo "## 🎉 Web Staging Deployment Successful!" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "- **Environment:** \`staging\`" >> $GITHUB_STEP_SUMMARY + echo "- **URL:** https://staging.buster.so" >> $GITHUB_STEP_SUMMARY + echo "- **Worker:** \`web-staging\`" >> $GITHUB_STEP_SUMMARY + echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Commit:** \`${SHA}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Full SHA:** \`${{ steps.commit.outputs.sha_full }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Triggered by:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY + echo "- **Time:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY + + - name: Handle deployment failure + if: failure() + run: | + echo "## ❌ Web Staging Deployment Failed!" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "- **Environment:** \`staging\`" >> $GITHUB_STEP_SUMMARY + echo "- **Error:** Check the logs above for details" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Next Steps:" >> $GITHUB_STEP_SUMMARY + echo "1. Review the error logs above" >> $GITHUB_STEP_SUMMARY + echo "2. Check Cloudflare dashboard for deployment status" >> $GITHUB_STEP_SUMMARY + echo "3. Verify GitHub secrets are configured correctly" >> $GITHUB_STEP_SUMMARY + echo "4. Verify staging environment variables in GitHub Secrets" >> $GITHUB_STEP_SUMMARY diff --git a/.gitignore b/.gitignore index 1d2874f2a..ff37f0456 100644 --- a/.gitignore +++ b/.gitignore @@ -93,4 +93,3 @@ drizzle/meta/ apps/web/.env.prod apps/web/.env.production apps/web/.env.staging -apps/web/wrangler.jsonc diff --git a/apps/web/.gitignore b/apps/web/.gitignore index 5ba795ca0..a27c2b8b2 100644 --- a/apps/web/.gitignore +++ b/apps/web/.gitignore @@ -18,4 +18,3 @@ storybook-static .env.staging .env.dev .env.local -wrangler.jsonc \ No newline at end of file diff --git a/apps/web/nitro.config.js b/apps/web/nitro.config.js index c8e2eb3d0..3380a41f8 100644 --- a/apps/web/nitro.config.js +++ b/apps/web/nitro.config.js @@ -2,54 +2,51 @@ const WARNING_SUPPRESSIONS = { MODULE_LEVEL_DIRECTIVE: { patterns: ["node_modules/"], - reason: "Suppress 'use client' directive warnings from dependencies" + reason: "Suppress 'use client' directive warnings from dependencies", }, THIS_IS_UNDEFINED: { patterns: ["node_modules/"], - reason: "Suppress 'this' keyword warnings in ES modules from dependencies" + reason: "Suppress 'this' keyword warnings in ES modules from dependencies", }, CIRCULAR_DEPENDENCY: { patterns: [ "nitropack/dist/runtime/internal/", "@tanstack/store/dist", - "juice/lib/" + "juice/lib/", ], - reason: "Suppress known third-party circular dependency warnings" - } + reason: "Suppress known third-party circular dependency warnings", + }, }; // Additional message-based suppressions const MESSAGE_SUPPRESSIONS = [ - "The 'this' keyword is equivalent to 'undefined'" + "The 'this' keyword is equivalent to 'undefined'", ]; function shouldSuppressWarning(warning) { const message = warning.message || ""; - + // Check code-based suppressions const suppression = WARNING_SUPPRESSIONS[warning.code]; if (suppression) { - return suppression.patterns.some(pattern => message.includes(pattern)); + return suppression.patterns.some((pattern) => message.includes(pattern)); } - + // Check message-based suppressions - return MESSAGE_SUPPRESSIONS.some(suppressionMessage => + return MESSAGE_SUPPRESSIONS.some((suppressionMessage) => message.includes(suppressionMessage) ); } export default { - // rollupConfig: { - // onwarn(warning, defaultHandler) { - // if (shouldSuppressWarning(warning)) { - // return; - // } - - // // Handle all other warnings normally - // defaultHandler(warning); - // }, - // onerror: (id) => { - // console.error(`Big nate: Error in ${id}`); - // }, - // }, + rollupConfig: { + onwarn(warning, defaultHandler) { + if (shouldSuppressWarning(warning)) { + return; + } + + // Handle all other warnings normally + defaultHandler(warning); + }, + }, }; diff --git a/apps/web/package.json b/apps/web/package.json index 92e9a132e..8fc01d663 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -8,8 +8,6 @@ "build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build -- --typecheck", "build:staging": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build --mode staging", "build:production": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build --mode production -- --typecheck", - "build:cloudflare": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192 --max-semi-space-size=256\" TYPECHECK=false vite build --mode production", - "build:cf-optimized": "cross-env NODE_OPTIONS=\"--max-old-space-size=7680 --optimize-for-size\" TYPECHECK=false vite build --mode production", "build:local": "cross-env NODE_OPTIONS=--max-old-space-size=12288 vite build -- --typecheck --local", "build-storybook": "storybook build", "build:visualize": "npx vite-bundle-visualizer", diff --git a/apps/web/wrangler.example.jsonc b/apps/web/wrangler.example.jsonc deleted file mode 100644 index e773d9c8c..000000000 --- a/apps/web/wrangler.example.jsonc +++ /dev/null @@ -1,47 +0,0 @@ -{ - "$schema": "node_modules/wrangler/config-schema.json", - "name": "web", - "main": "./.output/server/index.mjs", - "compatibility_date": "2025-09-02", //Happy birthday to Nate 🎉 - "compatibility_flags": ["nodejs_compat", "no_nodejs_compat_v2"], - - "assets": { - "directory": ".output/public" - }, - - "observability": { - "enabled": true - }, - - "env": { - // Development Environment - "dev": { - "name": "web-dev", - "vars": { - // Development-specific variables can be set here - // Or loaded from .env.dev file - } - }, - - // Staging Environment - "staging": { - "name": "web-staging", - "routes": [], - "vars": { - // Staging-specific variables can be set here - // Or loaded from .env.staging file - } - }, - - // Production Environment - "production": { - "name": "web-production", - "routes": [], - "vars": { - // Production-specific variables can be set here - // Or loaded from .env.production file - } - } - } - } - \ No newline at end of file diff --git a/apps/web/wrangler.jsonc b/apps/web/wrangler.jsonc new file mode 100644 index 000000000..57aab083b --- /dev/null +++ b/apps/web/wrangler.jsonc @@ -0,0 +1,65 @@ +{ + "$schema": "node_modules/wrangler/config-schema.json", + "name": "web", + "main": "./.output/server/index.mjs", + "compatibility_date": "2024-09-04", + "compatibility_flags": ["nodejs_compat"], + + "assets": { + "directory": ".output/public" + }, + + "observability": { + "enabled": true + }, + + "env": { + // Development Environment + "dev": { + "name": "web-dev", + "vars": { + // Development-specific variables can be set here + // Or loaded from .env.dev file + } + }, + + // Staging Environment + "staging": { + "name": "web-staging", + "routes": [ + { + "pattern": "staging.buster.so", + "custom_domain": true + } + ], + "vars": { + "VITE_PUBLIC_API_URL": "https://api2staging.buster.so", + "VITE_PUBLIC_URL": "https://staging.buster.so", + "VITE_PUBLIC_SUPABASE_URL": "https://vlelrtlxoixvaynaudau.supabase.co", + "VITE_PUBLIC_SUPABASE_ANON_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZsZWxydGx4b2l4dmF5bmF1ZGF1Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjM3MzEyNzgsImV4cCI6MjAzOTMwNzI3OH0.nK2gZggez6r_F00Ci_fcMXPle5HWo9boGQ5mG3CERFs", + "VITE_PUBLIC_POSTHOG_KEY": "phc_CtxCFcicGmtdan7MnQTRc3AypAifI7FYsoVFv3WnCQc", + "VITE_PUBLIC_API2_URL": "https://stagingapi.buster.so", + "VITE_PUBLIC_ENABLE_TANSTACK_PANEL": "true" + } + }, + + // Production Environment + "production": { + "name": "web-production", + "routes": [ + { + "pattern": "app.buster.so", + "custom_domain": true + } + ], + "vars": { + "VITE_PUBLIC_API_URL": "https://api.buster.so", + "VITE_PUBLIC_URL": "https://platform.buster.so", + "VITE_PUBLIC_SUPABASE_URL": "https://aofftppzkoydkyfrhrcj.supabase.co", + "VITE_PUBLIC_SUPABASE_ANON_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFvZmZ0cHB6a295ZGt5ZnJocmNqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjYzNTUzNDUsImV4cCI6MjA0MTkzMTM0NX0.sg_4VkZDpVDO51bMBsAOhNdU_AAXnH8bGqeK3UHHe-Q", + "VITE_PUBLIC_POSTHOG_KEY": "phc_CtxCFcicGmtdan7MnQTRc3AypAifI7FYsoVFv3WnCQc", + "VITE_PUBLIC_API2_URL": "https://api2.buster.so" + } + } + } +}