|
| 1 | +name: Deploy to Cloudflare Pages |
| 2 | + |
| 3 | +on: |
| 4 | + # Run after Versioning so semantic-release has created the release tag before |
| 5 | + # changelog:generate reads git history for the in-app changelog. |
| 6 | + workflow_run: |
| 7 | + workflows: [Versioning] |
| 8 | + types: [completed] |
| 9 | + branches: [main] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: cloudflare-pages |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + deploy: |
| 21 | + name: Deploy to Cloudflare Pages |
| 22 | + runs-on: ubuntu-latest |
| 23 | + env: |
| 24 | + VITE_PUBLIC_POSTHOG_KEY: ${{ secrets.VITE_PUBLIC_POSTHOG_KEY }} |
| 25 | + VITE_PUBLIC_POSTHOG_HOST: ${{ vars.VITE_PUBLIC_POSTHOG_HOST }} |
| 26 | + # Cloudflare Pages serves at the domain root, so no base path. |
| 27 | + VITE_BASE_PATH: / |
| 28 | + VITE_SITE_URL: https://torena-sim.pages.dev |
| 29 | + VITE_SUGGESTION_WORKER_URL: ${{ vars.VITE_SUGGESTION_WORKER_URL }} |
| 30 | + VITE_TURNSTILE_SITE_KEY: ${{ vars.VITE_TURNSTILE_SITE_KEY }} |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@v6.0.2 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + - name: Setup Bun |
| 39 | + uses: oven-sh/setup-bun@v2 |
| 40 | + |
| 41 | + - name: Setup Rust toolchain (wasm32) |
| 42 | + uses: dtolnay/rust-toolchain@stable |
| 43 | + with: |
| 44 | + targets: wasm32-unknown-unknown |
| 45 | + |
| 46 | + - name: Cache Rust build |
| 47 | + uses: swatinem/rust-cache@v2 |
| 48 | + with: |
| 49 | + workspaces: packages |
| 50 | + |
| 51 | + - name: Install wasm-pack |
| 52 | + uses: jetli/wasm-pack-action@v0.4.0 |
| 53 | + |
| 54 | + - name: Install dependencies |
| 55 | + run: bun install --frozen-lockfile |
| 56 | + |
| 57 | + - name: Generate changelog for build |
| 58 | + run: bun run changelog:generate |
| 59 | + |
| 60 | + - name: Run type check |
| 61 | + run: bun run typecheck |
| 62 | + |
| 63 | + - name: Run linter |
| 64 | + run: bun run lint |
| 65 | + |
| 66 | + - name: Build app |
| 67 | + run: bun run build |
| 68 | + |
| 69 | + - name: Add SPA fallback for client-side routing |
| 70 | + run: printf '/* /index.html 200\n' > dist/_redirects |
| 71 | + |
| 72 | + - name: Deploy to Cloudflare Pages |
| 73 | + uses: cloudflare/wrangler-action@v3 |
| 74 | + with: |
| 75 | + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 76 | + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 77 | + command: pages deploy dist --project-name=torena-sim --branch=main |
0 commit comments