refactor: split platform-specific code into platform-vercel and platform-cloudflare packages #9153
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
| # Security Notes | |
| # Only selected Actions are allowed within this repository. Please refer to (https://github.com/nodejs/nodejs.org/settings/actions) | |
| # for the full list of available actions. If you want to add a new one, please reach out a maintainer with Admin permissions. | |
| # REVIEWERS, please always double-check security practices before merging a PR that contains Workflow changes!! | |
| # AUTHORS, please only use actions with explicit SHA references, and avoid using `@master` or `@main` references or `@version` tags. | |
| name: Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| merge_group: | |
| defaults: | |
| run: | |
| # This ensures that the working directory is the root of the repository | |
| working-directory: ./ | |
| permissions: | |
| contents: read | |
| actions: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| build: | |
| name: Build on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - uses: nodejs/web-team/actions/setup-environment@9f3c83af227d721768d9dbb63009a47ed4f4282f | |
| with: | |
| pnpm: true | |
| use-version-file: true | |
| # We only want to install required production packages | |
| install-flags: --prod | |
| - name: Use GNU tar instead BSD tar | |
| # This ensures that we use GNU `tar` which is more efficient for extracting caches's | |
| if: matrix.os == 'windows-latest' | |
| shell: cmd | |
| run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" | |
| - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/apps/site/.next/cache | |
| ${{ github.workspace }}/apps/vercel/.next/cache | |
| ${{ github.workspace }}/apps/cloudflare/.next/cache | |
| key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
| restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
| - name: Build apps/site (standalone) | |
| # We want a ISR build on CI to ensure that regular Next.js builds work as expected. | |
| run: node_modules/.bin/turbo build --filter=@node-core/website --cache-dir=.turbo/cache | |
| env: | |
| NODE_OPTIONS: '--max_old_space_size=4096' | |
| TURBOPACK_STATS: ${{ matrix.os == 'ubuntu-latest' }} | |
| - name: Build apps/vercel (Vercel deployment target) | |
| # Ensures the Vercel deployment target builds with its platform-specific | |
| # `@analytics` slot + instrumentation wired through the shared site source. | |
| run: node_modules/.bin/turbo build --filter=@node-core/website-vercel --cache-dir=.turbo/cache | |
| env: | |
| NODE_OPTIONS: '--max_old_space_size=4096' | |
| TURBOPACK_STATS: ${{ matrix.os == 'ubuntu-latest' }} | |
| - name: Build apps/cloudflare (Cloudflare / OpenNext deployment target) | |
| # Ensures the Cloudflare deployment target builds with its Cloudflare | |
| # Images loader and MDX_WASM=false Shiki path. | |
| # Windows skip: OpenNext/wrangler asset polyfilling is POSIX-only. | |
| if: matrix.os == 'ubuntu-latest' | |
| run: node_modules/.bin/turbo cloudflare:build:worker --filter=@node-core/website-cloudflare --cache-dir=.turbo/cache | |
| env: | |
| NODE_OPTIONS: '--max_old_space_size=4096' | |
| - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| if: matrix.os == 'ubuntu-latest' | |
| with: | |
| name: webpack-stats | |
| path: apps/site/.next/server/webpack-stats.json | |
| - name: Build Next.js (Static Export) | |
| # We want to generate a static build, as it is a requirement of our website. | |
| run: node_modules/.bin/turbo deploy --filter=@node-core/website --cache-dir=.turbo/cache | |
| env: | |
| NODE_OPTIONS: '--max_old_space_size=4096' | |
| # We want to ensure that static exports for all locales do not occur on `pull_request` events | |
| # TODO: The output of this is too large, and it crashes the GitHub Runner | |
| NEXT_PUBLIC_STATIC_EXPORT_LOCALE: false # ${{ github.event_name == 'push' }} |