File tree Expand file tree Collapse file tree 8 files changed +50
-9
lines changed Expand file tree Collapse file tree 8 files changed +50
-9
lines changed Original file line number Diff line number Diff line change
1
+ name : Update Search Index
2
+
3
+ on :
4
+ push :
5
+ # Run when merging from official repo to check if translations are outdated
6
+ branches :
7
+ - main
8
+ workflow_dispatch : # Allow manual triggering
9
+
10
+ # Add permissions needed for creating PRs
11
+ permissions :
12
+ contents : write
13
+
14
+ jobs :
15
+ translate :
16
+ runs-on : ubuntu-latest
17
+ steps :
18
+ # Checkout the repository first to access local actions
19
+ - name : Checkout code
20
+ uses : actions/checkout@v3
21
+ with :
22
+ fetch-depth : 1
23
+ - name : Setup Tools
24
+ uses : ./.github/actions/setup
25
+ - name : Build docs app
26
+ shell : bash
27
+ run : pnpm build:docs
28
+ - name : Run search index update
29
+ shell : bash
30
+ run : pnpm run update-search-index
31
+ env :
32
+ ORAMA_PRIVATE_API_KEY_EN : ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
33
+ ORAMA_PRIVATE_API_KEY_ZH_HANS : ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}
34
+
Original file line number Diff line number Diff line change 1
1
EN_DOMAIN = nextjs.im
2
2
ZH_HANS_DOMAIN = zh-hans.nextjs.im
3
- ORAMA_PRIVATE_API_KEY =
3
+ ORAMA_PRIVATE_API_KEY_EN =
4
+ ORAMA_PRIVATE_API_KEY_ZH_HANS =
Original file line number Diff line number Diff line change 4
4
"private" : true ,
5
5
"scripts" : {
6
6
"build" : " next build" ,
7
- "build:post " : " tsx ./scripts/post-build .mts" ,
7
+ "update-search-index " : " tsx ./scripts/update-search-index .mts" ,
8
8
"dev" : " next dev --turbo" ,
9
9
"start" : " next start" ,
10
10
"postinstall" : " fumadocs-mdx" ,
Original file line number Diff line number Diff line change @@ -8,8 +8,11 @@ import { sync } from '../src/lib/orama/orama-cloud';
8
8
export async function updateSearchIndexes ( ) : Promise < void > {
9
9
for ( const item of ORAMA_CONFIGS ) {
10
10
const { locale, privateKey, index } = item ;
11
+ if ( ! privateKey ) {
12
+ console . error ( `No private key found for locale: ${ locale } ` ) ;
13
+ continue ;
14
+ }
11
15
const manager = new CloudManager ( { api_key : privateKey } ) ;
12
-
13
16
// Get all .body files in the static directory
14
17
const staticDir = path . join ( `.next/server/app/${ locale } /static` ) ;
15
18
let allRecords : OramaDocument [ ] = [ ] ;
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
import type { Locale } from 'next-intl' ;
2
- // PrivateApiKey is only used in the server
3
- const privateApiKey = process . env . ORAMA_PRIVATE_API_KEY ;
4
2
5
3
const ORAMA_EN_CONFIG = {
6
4
locale : 'en' ,
7
- privateKey : privateApiKey || '' ,
5
+ privateKey : process . env . ORAMA_PRIVATE_API_KEY_EN || '' ,
8
6
apiKey : '4DujbZrvGuklBRFcZBtegX3fV1lzNXnU' ,
9
7
index : 'vuywlowcbl1w3s2jtvq5ysxl' ,
10
8
endpoint : 'https://cloud.orama.run/v1/indexes/en-ai00ky' ,
@@ -14,7 +12,7 @@ type ORAMA_EN_CONFIG = typeof ORAMA_EN_CONFIG;
14
12
15
13
const OORAMA_ZH_HANS_CONFIG = {
16
14
locale : 'zh-Hans' ,
17
- privateKey : privateApiKey || '' ,
15
+ privateKey : process . env . ORAMA_PRIVATE_API_ZH_HANS || '' ,
18
16
apiKey : '6nEUS4tyXiajWxZ8qMEQMzzLoOYTuLSk' ,
19
17
index : 'vcwl00bwd64h3pa8yq8x107y' ,
20
18
endpoint : 'https://cloud.orama.run/v1/indexes/zh-hans-js5ujm' ,
Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ export async function sync(
31
31
) ;
32
32
await index . insert ( chunk ) ;
33
33
}
34
- if ( autoDeploy ) await index . deploy ( ) ;
34
+ if ( autoDeploy ) {
35
+ console . log ( 'Deploying index...' ) ;
36
+ await index . deploy ( ) ;
37
+ }
35
38
console . log ( 'All operations completed' ) ;
36
39
}
37
40
Original file line number Diff line number Diff line change 9
9
"lint" : " biome lint ." ,
10
10
"lint:fix" : " biome lint --write ." ,
11
11
"dev" : " pnpm --filter @next-i18n/translate --filter @next-i18n/docs --parallel dev" ,
12
- "translate" : " pnpm --filter @next-i18n/docs translate"
12
+ "translate" : " pnpm --filter @next-i18n/docs translate" ,
13
+ "build:docs" : " pnpm --filter @next-i18n/docs build" ,
14
+ "update-search-index" : " pnpm --filter @next-i18n/docs update-search-index"
13
15
},
14
16
"keywords" : [],
15
17
"devDependencies" : {
You can’t perform that action at this time.
0 commit comments