Skip to content

Commit a3aa99f

Browse files
authored
chore: setup multiple docsites deploy to GHP (microsoft#35151)
1 parent a7484f9 commit a3aa99f

File tree

10 files changed

+64
-27
lines changed

10 files changed

+64
-27
lines changed

.github/workflows/docsite-publish-ghpages.yml

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,10 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
check:
12-
runs-on: ubuntu-latest
13-
if: ${{ github.repository_owner == 'microsoft' }} && ${{ contains(github.event.head_commit.message, 'applying package updates') || github.event_name == 'workflow_dispatch' }}
14-
15-
outputs:
16-
status: ${{ steps.verify-react-components-changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' }}
17-
18-
steps:
19-
- uses: actions/checkout@v4
20-
name: Checkout [master]
21-
22-
- name: Verify react-compoenents has changed
23-
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
24-
id: verify-react-components-changed
25-
with:
26-
files: |
27-
packages/react-components/react-components/package.json
2811
build:
2912
runs-on: ubuntu-latest
30-
needs: check
31-
if: needs.check.outputs.status == 'true'
13+
outputs:
14+
artifact_id: ${{ steps.artifact_upload.outputs.artifact_id }}
3215

3316
steps:
3417
- uses: actions/checkout@v4
@@ -46,20 +29,39 @@ jobs:
4629
- name: Install Playwright Browsers
4730
run: yarn playwright install --with-deps
4831

49-
- name: Build storybook
50-
run: yarn nx run public-docsite-v9:build-storybook --nxBail
51-
env:
52-
STORYBOOK_APPINSIGHTS_INSTRUMENTATION_KEY: ${{ secrets.STORYBOOK_APPINSIGHTS_INSTRUMENTATION_KEY }}
32+
- name: Affected Deployable Storybooks
33+
id: affected_storybooks_count
34+
run: |
35+
affected_count=$(yarn --silent nx show projects -t build-storybook:docsite --affected --verbose false | wc -l | tr -d ' ')
36+
echo "value=$affected_count" >> $GITHUB_OUTPUT
37+
38+
- name: Build affected storybooks
39+
if: steps.affected_storybooks_count.outputs.value > 0
40+
run: |
41+
yarn nx run-many -t build-storybook:docsite --nxBail
42+
43+
- name: Prepare Artifact
44+
if: steps.affected_storybooks_count.outputs.value > 0
45+
run: |
46+
rm -rf _pages
47+
mkdir -p _pages/react _pages/charts _pages/web-components
48+
49+
cp -R apps/public-docsite-v9/dist/storybook/* _pages/
50+
cp -R apps/public-docsite-v9/dist/react/* _pages/react/
51+
cp -R apps/chart-docsite/dist/storybook/* _pages/charts/
52+
cp -R packages/web-components/dist/storybook/* _pages/web-components
5353
5454
- name: Upload Pages Artifact
55+
if: steps.affected_storybooks_count.outputs.value > 0
56+
id: artifact_upload
5557
uses: actions/upload-pages-artifact@v3
5658
with:
57-
path: './apps/public-docsite-v9/dist/storybook/'
59+
path: _pages
5860

5961
deploy:
6062
runs-on: ubuntu-latest
6163
needs: build
62-
64+
if: needs.build.outputs.artifact_id
6365
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
6466
permissions:
6567
pages: write # to deploy to Pages

apps/chart-docsite/.storybook/main.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ import type { StorybookConfig } from '@storybook/react-webpack5';
33
// eslint-disable-next-line @nx/enforce-module-boundaries
44
import rootConfig from '../../../.storybook/main';
55

6-
const config: StorybookConfig = {
6+
const config = {
77
...rootConfig,
8+
build: {
9+
previewUrl: process.env.DEPLOY_PATH,
10+
},
811
stories: [
912
// docsite stories
1013
'../src/**/*.mdx',
1114
'../src/**/index.stories.@(js|jsx|ts|tsx)',
1215
// packages stories
1316
'../../../packages/charts/react-charts/stories/**/index.stories.@(js|jsx|ts|tsx)',
1417
],
15-
};
18+
} satisfies StorybookConfig;
1619

1720
export default config;

apps/chart-docsite/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "Fluent UI React Charts Preview documentation",
66
"scripts": {
77
"build-storybook": "storybook build -o ./dist/storybook --docs",
8+
"build-storybook:docsite": "cross-env DEPLOY_PATH=/charts/ storybook build -o ./dist/storybook --docs",
89
"postbuild-storybook": "yarn rewrite-title && yarn generate-llms-docs",
910
"rewrite-title": "node -r ../../scripts/ts-node/src/register ../../scripts/storybook/src/scripts/rewrite-title.ts --title 'Fluent UI Charts v9' --distPath ./dist/storybook",
1011
"generate-llms-docs": "yarn storybook-llms-extractor --distPath ./dist/storybook --summaryBaseUrl \"https://fluentuipr.z22.web.core.windows.net/pull/34838/chart-docsite/storybook\" --summaryTitle \"Fluent UI Charts v9\" --summaryDescription \"Fluent UI React charts is a set of modern, accessible, interactive, lightweight and highly customizable visualization library representing the Microsoft design system. These charts are used across 100s of projects inside Microsoft across Microsoft 365, Copilot and Azure.\"",

apps/public-docsite-v9/.storybook/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript
3333
],
3434
staticDirs: ['../public'],
3535
addons: [...rootMain.addons],
36+
build: {
37+
previewUrl: process.env.DEPLOY_PATH,
38+
},
3639
webpackFinal: (config, options) => {
3740
const localConfig = /** @type config */ ({ ...rootMain.webpackFinal?.(config, options) });
3841

apps/public-docsite-v9/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "Fluent UI React v9 documentation",
66
"scripts": {
77
"build-storybook": "cross-env NODE_OPTIONS=--max_old_space_size=3072 storybook build -o ./dist/storybook --docs",
8+
"build-storybook:react": "cross-env NODE_OPTIONS=--max_old_space_size=3072 DEPLOY_PATH=/react/ storybook build -o ./dist/react --docs",
89
"postbuild-storybook": "yarn rewrite-title && yarn generate-llms-docs",
910
"rewrite-title": "node -r ../../scripts/ts-node/src/register ../../scripts/storybook/src/scripts/rewrite-title.ts --title 'Fluent UI React v9' --distPath ./dist/storybook",
1011
"generate-llms-docs": "yarn storybook-llms-extractor --config storybook-llms.config.js",

apps/public-docsite-v9/project.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212
"target": "build"
1313
}
1414
]
15+
},
16+
"build-storybook:react": {
17+
"inputs": ["default", "{workspaceRoot}/.storybook/**", "{projectRoot}/.storybook/**"],
18+
"outputs": ["{projectRoot}/dist/react"]
19+
},
20+
"build-storybook:docsite": {
21+
"executor": "nx:noop",
22+
"dependsOn": [
23+
"build-storybook",
24+
"build-storybook:react",
25+
{
26+
"projects": ["chart-docsite", "web-components"],
27+
"target": "build-storybook:docsite"
28+
}
29+
]
1530
}
1631
}
1732
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "chore: setup docsite target",
4+
"packageName": "@fluentui/web-components",
5+
"email": "[email protected]",
6+
"dependentChangeType": "none"
7+
}

nx.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"build-storybook": {
2222
"dependsOn": [],
23+
"outputs": ["{projectRoot}/dist/storybook"],
2324
"inputs": ["default", "{workspaceRoot}/.storybook/**", "{projectRoot}/.storybook/**"],
2425
"cache": true
2526
},

packages/web-components/.storybook/main.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ module.exports =
3535
},
3636
},
3737
],
38+
build: {
39+
previewUrl: process.env.DEPLOY_PATH,
40+
},
3841
webpackFinal: async config => {
3942
config.resolve = config.resolve ?? {};
4043
config.resolve.extensions = config.resolve.extensions ?? [];

packages/web-components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"start": "yarn start-storybook -p 6006 --docs",
6868
"start-storybook": "storybook dev",
6969
"build-storybook": "storybook build -o ./dist/storybook --docs",
70+
"build-storybook:docsite": "cross-env DEPLOY_PATH=/web-components/ storybook build -o ./dist/storybook --docs",
7071
"e2e": "node ./scripts/e2e.js",
7172
"e2e:local": "node ./scripts/e2e.js --ui"
7273
},

0 commit comments

Comments
 (0)