chore: Clean up codebase - remove junk files and debug code #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Widget to Cloudflare R2 | |
| on: | |
| push: | |
| paths: | |
| - 'widget/**' | |
| - 'shared/**' | |
| branches: | |
| - main | |
| pull_request: | |
| paths: | |
| - 'widget/**' | |
| - 'shared/**' | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag (e.g., v1.0.0) - optional, uses latest if not provided' | |
| required: false | |
| type: string | |
| env: | |
| NODE_VERSION: '20' | |
| PNPM_VERSION: '8.15.0' | |
| R2_BUCKET: 'syntera-widget' | |
| jobs: | |
| build-and-deploy: | |
| name: Build and Deploy Widget | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build shared package | |
| run: pnpm --filter @syntera/shared build | |
| - name: Build widget | |
| working-directory: widget | |
| run: | | |
| pnpm build || (echo "❌ Build failed" && exit 1) | |
| if [ ! -f "dist/widget.js" ] || [ ! -f "dist/widget.css" ]; then | |
| echo "❌ Build failed: widget.js or widget.css not found" | |
| ls -la dist/ || echo "dist directory does not exist" | |
| exit 1 | |
| fi | |
| echo "✅ Build successful" | |
| ls -lh dist/widget.* | |
| - name: Install Wrangler | |
| run: npm install -g wrangler | |
| - name: Deploy to Cloudflare R2 (latest) | |
| working-directory: widget | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| run: | | |
| echo "📤 Uploading widget.js to R2..." | |
| wrangler r2 object put ${{ env.R2_BUCKET }}/widget.js \ | |
| --file=dist/widget.js \ | |
| --remote || (echo "❌ Failed to upload widget.js" && exit 1) | |
| echo "📤 Uploading widget.css to R2..." | |
| wrangler r2 object put ${{ env.R2_BUCKET }}/widget.css \ | |
| --file=dist/widget.css \ | |
| --remote || (echo "❌ Failed to upload widget.css" && exit 1) | |
| echo "✅ Deployment complete!" | |
| - name: Deploy versioned files (if version provided) | |
| if: github.event.inputs.version != '' | |
| working-directory: widget | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| VERSION: ${{ github.event.inputs.version }} | |
| run: | | |
| VERSION_DIR="$VERSION" | |
| echo "📤 Uploading versioned files to R2 ($VERSION_DIR/)..." | |
| wrangler r2 object put ${{ env.R2_BUCKET }}/$VERSION_DIR/widget.js \ | |
| --file=dist/widget.js \ | |
| --remote || (echo "❌ Failed to upload versioned widget.js" && exit 1) | |
| wrangler r2 object put ${{ env.R2_BUCKET }}/$VERSION_DIR/widget.css \ | |
| --file=dist/widget.css \ | |
| --remote || (echo "❌ Failed to upload versioned widget.css" && exit 1) | |
| echo "✅ Versioned deployment complete: $VERSION_DIR" | |
| - name: Deployment Summary | |
| run: | | |
| echo "## 🚀 Widget Deployment Complete" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Bucket:** ${{ env.R2_BUCKET }}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Public URL:** https://pub-487d70fa1de84574af35bd20e7e86e60.r2.dev" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 📦 Files Deployed:" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`widget.js\` → \`/${{ env.R2_BUCKET }}/widget.js\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`widget.css\` → \`/${{ env.R2_BUCKET }}/widget.css\`" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ github.event.inputs.version }}" != "" ]; then | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 🏷️ Versioned Files:" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`${{ github.event.inputs.version }}/widget.js\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`${{ github.event.inputs.version }}/widget.css\`" >> $GITHUB_STEP_SUMMARY | |
| fi | |