Skip to content

Commit f374e2b

Browse files
committed
Try matrix build strategy
Signed-off-by: Joshua Castle <[email protected]>
1 parent 163a667 commit f374e2b

File tree

5 files changed

+102
-6
lines changed

5 files changed

+102
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ concurrency:
2626
cancel-in-progress: true
2727

2828
jobs:
29-
build:
29+
sync:
3030
name: Deploy to GitHub Pages
3131
runs-on: ubuntu-latest
3232
steps:
@@ -41,9 +41,6 @@ jobs:
4141
with:
4242
fetch-depth: 0
4343

44-
- name: Setup Pages
45-
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b
46-
4744
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
4845
with:
4946
node-version: 22
@@ -78,13 +75,84 @@ jobs:
7875
env:
7976
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
8077

81-
- name: Build website
82-
run: yarn build
78+
- name: Get locales
79+
run: yarn output-locales
80+
81+
- name: Define matrix
82+
id: locales
83+
run: echo "locales=$(cat locales.json)" >> $GITHUB_ENV
84+
85+
build:
86+
runs-on: ubuntu-latest
87+
needs: sync
88+
strategy:
89+
matrix:
90+
locales: ${{ fromJson(needs.sync.outputs.locales) }}
91+
steps:
92+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
93+
with:
94+
node-version: 22
95+
96+
- name: Enable Corepack
97+
run: corepack enable
98+
99+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
100+
with:
101+
fetch-depth: 0
102+
103+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
104+
with:
105+
node-version: 22
106+
cache: yarn
107+
108+
- name: Install dependencies
109+
run: yarn install --immutable
110+
111+
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
112+
with:
113+
path: |
114+
${{ github.workspace }}/.docusaurus
115+
${{ github.workspace }}/**/.cache
116+
key: |
117+
${{ runner.os }}-docusaurus-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
118+
restore-keys: |
119+
${{ runner.os }}-docusaurus-${{ hashFiles('**/yarn.lock') }}
120+
121+
- name: Build Locale
122+
run: yarn build --locale ${{ matrix.locales }}
123+
124+
- name: Upload artifact
125+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1
126+
with:
127+
path: build
128+
name: ${{ matrix.locales }}
129+
130+
combine:
131+
runs-on: ubuntu-latest
132+
needs: build
133+
steps:
134+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
135+
with:
136+
fetch-depth: 0
137+
138+
- name: Setup Pages
139+
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b
140+
141+
- name: Download artifacts
142+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
143+
with:
144+
path: build
145+
146+
- name: Move default locale to root build
147+
run: |
148+
mv build/en/* build/
149+
rm -rf build/en
83150
84151
- name: Upload artifact
85152
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa
86153
with:
87154
path: build
155+
88156
deploy:
89157
environment:
90158
name: github-pages

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ vendor
2222
.env.development.local
2323
.env.test.local
2424
.env.production.local
25+
locales.json
2526

2627
npm-debug.log*
2728
yarn-debug.log*

docusaurus.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const config: Config = {
120120
jsonKeyExclusions: [ 'providers.provider.' ]
121121
}
122122
],
123+
'./src/plugins/output-locales.ts',
123124
'./src/plugins/modify-webpack.ts',
124125
],
125126
themes: ["docusaurus-theme-openapi-docs"],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"gen-all": "docusaurus gen-api-docs all && docusaurus gen-api-docs:version petstore_versioned:all",
2121
"clean-all": "docusaurus clean-api-docs all && docusaurus clean-api-docs:version petstore_versioned:all",
2222
"crowdin-sync": "docusaurus crowdin-sync",
23+
"output-locales": "docusaurus output-locales",
2324
"re-gen": "yarn clean-all && yarn gen-all",
2425
"typecheck": "tsc"
2526
},

src/plugins/output-locales.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import {LoadContext, Plugin, PluginOptions} from '@docusaurus/types';
4+
5+
const PLUGIN_NAME = 'docusaurus-plugin-output-locales';
6+
7+
const ouputLocalesPlugin = (context: LoadContext, options: PluginOptions): Plugin => {
8+
return {
9+
name: PLUGIN_NAME,
10+
extendCli(cli) {
11+
cli
12+
.command('output-locales')
13+
.description('Sync translations with Crowdin')
14+
.action(async () => {
15+
fs.writeFileSync(
16+
path.join(context.siteDir, 'locales.json'),
17+
JSON.stringify(context.siteConfig.i18n.locales),
18+
'utf-8'
19+
)
20+
});
21+
}
22+
};
23+
}
24+
25+
export default ouputLocalesPlugin;

0 commit comments

Comments
 (0)