Skip to content

Commit 5201e76

Browse files
committed
fixup! chore: setup multiple storybooks to deploy
1 parent 5da1c2a commit 5201e76

8 files changed

Lines changed: 23 additions & 115 deletions

File tree

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

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +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-
outputs:
15-
status: ${{ steps.decide.outputs.should_build }}
16-
affected_projects: ${{ steps.affected.outputs.affected_projects }}
17-
18-
steps:
19-
- uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 0
22-
23-
- uses: actions/setup-node@v4
24-
with:
25-
node-version: 20
26-
cache: 'yarn'
27-
28-
- name: Install dependencies
29-
run: yarn install --frozen-lockfile
30-
31-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
32-
uses: nrwl/nx-set-shas@826660b82addbef3abff5fa871492ebad618c9e1 # v4.3.3
33-
with:
34-
main-branch-name: 'master'
35-
36-
- name: Compute affected projects (v9, charts, web components)
37-
id: affected
38-
shell: bash
39-
run: |
40-
RAW_AFFECTED="$(yarn nx show projects --affected --projects='public-docsite-v9,chart-docsite,web-components')"
41-
AFFECTED="$(echo "$RAW_AFFECTED" | tr '\n' ',' | sed 's/,$//')"
42-
echo "Affected projects: $AFFECTED"
43-
echo "affected_projects=${AFFECTED}" >> "$GITHUB_OUTPUT"
44-
45-
- name: Decide whether to build
46-
id: decide
47-
shell: bash
48-
run: |
49-
SHOULD_BUILD="false"
50-
if [ -n "${{ steps.affected.outputs.affected_projects }}" ]; then
51-
SHOULD_BUILD="true"
52-
fi
53-
echo "should_build=${SHOULD_BUILD}" >> "$GITHUB_OUTPUT"
54-
5511
build:
5612
runs-on: ubuntu-latest
57-
needs: check
58-
if: needs.check.outputs.status == 'true'
13+
outputs:
14+
artifact_id: ${{ steps.artifact_upload.outputs.artifact_id }}
5915

6016
steps:
6117
- uses: actions/checkout@v4
@@ -74,23 +30,28 @@ jobs:
7430
# run: yarn playwright install --with-deps
7531
#
7632
#
33+
- name: Affected Deployable Storybooks
34+
id: affected_storybooks_count
35+
run: |
36+
affected_count=$(yarn --silent nx show projects -t build-storybook:docsite --affected --verbose false | wc -l | tr -d ' ')
37+
echo "value=$affected_count" >> $GITHUB_OUTPUT
38+
7739
- name: Build affected storybooks
78-
if: ${{ needs.check.outputs.affected_projects != '' }}
79-
env:
80-
AFFECTED: ${{ needs.check.outputs.affected_projects }}
81-
STORYBOOK_APPINSIGHTS_INSTRUMENTATION_KEY: ${{ secrets.STORYBOOK_APPINSIGHTS_INSTRUMENTATION_KEY }}
40+
if: steps.affected_storybooks_count.outputs.value > 0
8241
run: |
83-
yarn nx run-many -t deploy-website -p "$AFFECTED" --parallel=3 --nxBail
42+
yarn nx run-many -t build-storybook:docsite --nxBail
8443
8544
- name: Upload Pages Artifact
45+
if: steps.affected_storybooks_count.outputs.value > 0
46+
id: artifact_upload
8647
uses: actions/upload-pages-artifact@v3
8748
with:
8849
path: './apps/public-docsite-v9/dist/'
8950

9051
deploy:
9152
runs-on: ubuntu-latest
9253
needs: build
93-
54+
if: needs.build.outputs.artifact_id
9455
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
9556
permissions:
9657
pages: write # to deploy to Pages

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 ../public-docsite-v9/dist/charts/ --docs",
89
"postbuild-storybook": "yarn rewrite-title",
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/chart-docsite/project.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
"target": "build"
1313
}
1414
]
15-
},
16-
"deploy-website": {
17-
"executor": "nx:run-commands",
18-
"options": {
19-
"cwd": "apps/chart-docsite",
20-
"commands": [
21-
"cross-env DEPLOY_PATH=/charts/ storybook build --docs -o ../public-docsite-v9/dist/charts/",
22-
"node -r ../../scripts/ts-node/src/register ../../scripts/storybook/src/scripts/rewrite-title.ts --title 'Fluent UI Charts v9' --distPath ../public-docsite-v9/dist/charts/"
23-
],
24-
"parallel": false
25-
}
2615
}
2716
}
2817
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript
3434
staticDirs: ['../public'],
3535
addons: [...rootMain.addons],
3636
build: {
37-
previewUrl: process.env.DEPLOY_PATH,
37+
previewUrl: process.env.DEPLOY_PATH ?? '/',
3838
},
3939
webpackFinal: (config, options) => {
4040
const localConfig = /** @type config */ ({ ...rootMain.webpackFinal?.(config, options) });

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",
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: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,16 @@
55
"implicitDependencies": ["tag:type:stories"],
66
"tags": ["platform:web", "vNext"],
77
"targets": {
8-
"build-storybook": {
9-
"executor": "nx:run-commands",
10-
"options": {
11-
"cwd": "apps/public-docsite-v9",
12-
"env": {
13-
"NODE_OPTIONS": "--max_old_space_size=3072"
14-
},
15-
"command": "storybook build -o ./dist/storybook --docs"
16-
},
17-
"configurations": {
18-
"react": {
19-
"cwd": "apps/public-docsite-v9",
20-
"env": { "DEPLOY_PATH": "/react/", "NODE_OPTIONS": "--max_old_space_size=3072" },
21-
"command": "storybook build -o ./dist/react --docs"
22-
}
23-
},
24-
"dependsOn": [
25-
{
26-
"projects": ["react-storybook-addon", "react-storybook-addon-export-to-sandbox", "storybook-llms-extractor"],
27-
"target": "build"
28-
}
29-
]
30-
},
31-
"build-docsites": {
32-
"executor": "nx:run-commands",
33-
"options": {
34-
"commands": [
35-
"yarn nx run public-docsite-v9:build-storybook",
36-
"yarn nx run public-docsite-v9:build-storybook:react"
37-
]
38-
},
8+
"build-storybook:docsite": {
9+
"executor": "nx:noop",
3910
"dependsOn": [
11+
"build-storybook",
12+
"build-storybook:react",
4013
{
4114
"projects": ["chart-docsite", "web-components"],
42-
"target": "deploy-website"
15+
"target": "build-storybook:docsite"
4316
}
4417
]
45-
},
46-
"deploy-website": {
47-
"dependsOn": ["build-docsites"],
48-
"executor": "nx:run-commands",
49-
"options": {
50-
"cwd": "apps/public-docsite-v9",
51-
"commands": [
52-
"node -r ../../scripts/ts-node/src/register ../../scripts/storybook/src/scripts/rewrite-title.ts --title 'Fluent UI React v9' --distPath ./dist/react/"
53-
]
54-
}
5518
}
5619
}
5720
}

packages/web-components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"start": "yarn start-storybook -p 6006 --docs",
6666
"start-storybook": "storybook dev",
6767
"build-storybook": "storybook build -o ./dist/storybook --docs",
68+
"build-storybook:docsite": "cross-env DEPLOY_PATH=/web-components/ storybook build -o ../../apps/public-docsite-v9/dist/web-components --docs",
6869
"e2e": "node ./scripts/e2e.js",
6970
"e2e:local": "node ./scripts/e2e.js --ui"
7071
},

packages/web-components/project.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,5 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"projectType": "library",
55
"implicitDependencies": [],
6-
"tags": ["platform:web", "web-components"],
7-
"targets": {
8-
"deploy-website": {
9-
"executor": "nx:run-commands",
10-
"options": {
11-
"command": "cross-env DEPLOY_PATH=/web-components/ yarn nx run web-components:build-storybook -o ../../apps/public-docsite-v9/dist/web-components"
12-
}
13-
}
14-
}
6+
"tags": ["platform:web", "web-components"]
157
}

0 commit comments

Comments
 (0)