Skip to content

Commit 03e8834

Browse files
authored
feat(Orama): don't rely on static build (#8107)
* feat(orama): don't rely on static builds * Update sync-orama-cloud job conditions Signed-off-by: Aviv Keller <[email protected]> * code review * fixup! --------- Signed-off-by: Aviv Keller <[email protected]>
1 parent ba84686 commit 03e8834

File tree

16 files changed

+476
-440
lines changed

16 files changed

+476
-440
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ on:
1010
push:
1111
branches:
1212
- main
13-
pull_request_target:
13+
pull_request:
1414
branches:
1515
- main
16-
types:
17-
- labeled
1816
merge_group:
19-
workflow_dispatch:
2017

2118
defaults:
2219
run:
@@ -33,11 +30,6 @@ env:
3330

3431
jobs:
3532
build:
36-
# This Job should run either on non-`pull_request_target` events,
37-
# or `pull_request_target` event with a `labeled` action with a label named `github_actions:pull-request`
38-
# since we want to run Website Builds on all these occasions. As this allows us to be certain the that builds are passing
39-
if: github.event_name != 'pull_request_target' || github.event.label.name == 'github_actions:pull-request'
40-
4133
name: Build on ${{ matrix.os }}
4234
runs-on: ${{ matrix.os }}
4335

@@ -60,15 +52,6 @@ jobs:
6052

6153
- name: Git Checkout
6254
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
63-
with:
64-
# Provides the Pull Request commit SHA or the GitHub merge group ref
65-
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
66-
# We only need to fetch the last commit from the head_ref
67-
# since we're not using the `--filter` operation from turborepo
68-
# We don't use the `--filter` as we always want to force builds regardless of having changes or not
69-
# this ensures that our bundle analysis script always runs and that we always ensure next.js is building
70-
# regardless of having code changes or not
71-
fetch-depth: 1
7255

7356
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
7457
with:
@@ -90,59 +73,13 @@ jobs:
9073
# We only want to install required production packages
9174
run: pnpm install --prod --frozen-lockfile
9275

93-
- name: Build Next.js (ISR)
76+
- name: Build Next.js
9477
# We want a ISR build on CI to ensure that regular Next.js builds work as expected.
9578
run: node_modules/.bin/turbo build ${{ env.TURBO_ARGS }}
9679
env:
9780
# We want to ensure we have enough RAM allocated to the Node.js process
9881
# this should be a last resort in case by any chances the build memory gets too high
9982
# but in general this should never happen
10083
NODE_OPTIONS: '--max_old_space_size=4096'
101-
# Used for API requests that require GitHub API scopes
102-
NEXT_GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }}
103-
104-
- name: Build Next.js (Static All Locales)
105-
# We only run full static builds within Pull Requests. This step is also used to export
106-
# static output in all languages, and it only works on `push` events.
107-
if: github.event_name == 'push'
108-
run: node_modules/.bin/turbo deploy ${{ env.TURBO_ARGS }}
109-
env:
110-
# We want to ensure we have enough RAM allocated to the Node.js process
111-
# this should be a last resort in case by any chances the build memory gets too high
112-
# but in general this should never happen
113-
NODE_OPTIONS: '--max_old_space_size=4096'
114-
# Used for API requests that require GitHub API scopes
115-
NEXT_GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }}
116-
# We want to ensure that static exports for all locales are triggered only on `push` events to save resources
117-
# and time.
118-
NEXT_PUBLIC_STATIC_EXPORT_LOCALE: true
119-
120-
- name: Build Next.js (Static Default Locale)
121-
# We want to generate static output in the default language within Pull Requests
122-
# in order to reduce source wastages and build times.
123-
# Note that we skip full static builds on Crowdin-based Pull Requests as these PRs should only contain translation changes
124-
if: |
125-
(github.event_name == 'pull_request_target' &&
126-
github.event.pull_request.head.ref != 'chore/crowdin')
127-
run: node_modules/.bin/turbo deploy ${{ env.TURBO_ARGS }}
128-
env:
129-
# We want to ensure we have enough RAM allocated to the Node.js process
130-
# this should be a last resort in case by any chances the build memory gets too high
131-
# but in general this should never happen
132-
NODE_OPTIONS: '--max_old_space_size=4096'
133-
# Used for API requests that require GitHub API scopes
134-
NEXT_GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }}
135-
# We want to ensure that static exports for all locales do not occur on `pull_request_target` events
136-
NEXT_PUBLIC_STATIC_EXPORT_LOCALE: false
137-
138-
- name: Sync Orama Cloud
139-
# We only want to sync the Orama Cloud production indexes on `push` events.
140-
# We also want to sync the Orama Cloud preview (deployment) indexes on `pull_request_target` events (or manual triggers).
141-
# We also want to ensure that the sync only happens on the `ubuntu-latest` runner to avoid duplicate syncs
142-
# or Windows-based path issues.
143-
env:
144-
ORAMA_INDEX_ID: ${{ github.event_name == 'push' && secrets.ORAMA_PRODUCTION_INDEX_ID || secrets.ORAMA_INDEX_ID }}
145-
ORAMA_SECRET_KEY: ${{ github.event_name == 'push' && secrets.ORAMA_PRODUCTION_SECRET_KEY || secrets.ORAMA_SECRET_KEY }}
146-
if: matrix.os == 'ubuntu-latest' && github.event_name != 'merge_group'
147-
working-directory: apps/site
148-
run: node --run sync-orama
84+
# We want to ensure that static exports for all locales do not occur on `pull_request` events
85+
NEXT_PUBLIC_STATIC_EXPORT_LOCALE: ${{ github.event_name == 'push' }}

.github/workflows/sync-orama.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Security Notes
2+
# This workflow uses `pull_request_target`, so will run against all PRs automatically (without approval), be careful with allowing any user-provided code to be run here
3+
# Only selected Actions are allowed within this repository. Please refer to (https://github.com/nodejs/nodejs.org/settings/actions)
4+
# for the full list of available actions. If you want to add a new one, please reach out a maintainer with Admin permissions.
5+
# REVIEWERS, please always double-check security practices before merging a PR that contains Workflow changes!!
6+
# AUTHORS, please only use actions with explicit SHA references, and avoid using `@master` or `@main` references or `@version` tags.
7+
# MERGE QUEUE NOTE: This Workflow does not run on `merge_group` trigger, as this Workflow is not required for Merge Queue's
8+
9+
name: Sync Orama Cloud
10+
11+
on:
12+
push:
13+
branches:
14+
- main
15+
pull_request_target:
16+
branches:
17+
- main
18+
types:
19+
- labeled
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
sync-orama-cloud:
26+
name: Sync Orama Cloud
27+
runs-on: ubuntu-latest
28+
29+
# This Job should run either on non-`pull_request_target` events,
30+
# or `pull_request_target` event with a `labeled` action with a label named `github_actions:pull-request`
31+
# since we want to run Website Builds on all these occasions. As this allows us to be certain the that builds are passing
32+
if: github.event_name != 'pull_request_target' || github.event.label.name == 'github_actions:pull-request'
33+
34+
steps:
35+
- name: Git Checkout
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
with:
38+
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
39+
40+
- name: Set up pnpm
41+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
42+
43+
- name: Set up Node.js
44+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
45+
with:
46+
# We want to ensure that the Node.js version running here respects our supported versions
47+
node-version-file: '.nvmrc'
48+
cache: 'pnpm'
49+
50+
- name: Install packages
51+
run: pnpm install --frozen-lockfile
52+
53+
- name: Sync Orama Cloud
54+
working-directory: apps/site
55+
run: node --run sync-orama
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
ORAMA_INDEX_ID: ${{ github.event_name == 'push' && secrets.ORAMA_PRODUCTION_INDEX_ID || secrets.ORAMA_INDEX_ID }}
59+
ORAMA_SECRET_KEY: ${{ github.event_name == 'push' && secrets.ORAMA_PRODUCTION_SECRET_KEY || secrets.ORAMA_SECRET_KEY }}

apps/site/app/[locale]/next-data/api-data/route.ts

Lines changed: 0 additions & 89 deletions
This file was deleted.

apps/site/app/[locale]/next-data/page-data/route.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

apps/site/next.constants.mjs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,6 @@ export const ORAMA_CLOUD_ENDPOINT =
161161
export const ORAMA_CLOUD_API_KEY =
162162
process.env.NEXT_PUBLIC_ORAMA_API_KEY || 'qopIuAERiWP2EZOpDjvczjws7WV40yrj';
163163

164-
/**
165-
* A GitHub Access Token for accessing the GitHub API and not being rate-limited
166-
* The current token is registered on the "nodejs-vercel" GitHub Account.
167-
*
168-
* Note: This has no NEXT_PUBLIC prefix as it should not be exposed to the Browser.
169-
*/
170-
export const GITHUB_API_KEY = process.env.NEXT_GITHUB_API_KEY || '';
171-
172164
/**
173165
* The resource we point people to when discussing internationalization efforts.
174166
*/

apps/site/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"@testing-library/user-event": "~14.6.1",
8888
"@types/mdx": "^2.0.13",
8989
"@types/semver": "~7.7.0",
90+
"dedent": "^1.6.0",
9091
"eslint-config-next": "15.5.0",
9192
"eslint-import-resolver-typescript": "~4.4.4",
9293
"eslint-plugin-mdx": "~3.6.2",
@@ -95,6 +96,9 @@
9596
"global-jsdom": "^26.0.0",
9697
"handlebars": "4.7.8",
9798
"jsdom": "^26.0.0",
99+
"mdast-util-from-markdown": "^2.0.2",
100+
"mdast-util-to-string": "^4.0.0",
101+
"nock": "^14.0.10",
98102
"remark-frontmatter": "^5.0.0",
99103
"stylelint": "16.23.0",
100104
"stylelint-config-standard": "39.0.0",

0 commit comments

Comments
 (0)