File tree Expand file tree Collapse file tree
apps/storybook/.storybook Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # CI: lint, test, Turbo build; upload Storybook static site; deploy to GitHub Pages (main only).
2+ #
3+ # Manual setup (once per repo): Settings → Pages → Build and deployment → Source: GitHub Actions.
4+ # If prompted, approve the `github-pages` environment for this workflow.
5+
6+ name : CI and Storybook
7+
8+ on :
9+ push :
10+ branches : [main]
11+ pull_request :
12+ branches : [main]
13+
14+ concurrency :
15+ group : ${{ github.workflow }}-${{ github.ref }}
16+ cancel-in-progress : true
17+
18+ permissions :
19+ contents : read
20+ pages : write
21+ id-token : write
22+
23+ jobs :
24+ ci :
25+ runs-on : ubuntu-latest
26+ steps :
27+ - uses : actions/checkout@v6.0.2
28+
29+ - uses : pnpm/action-setup@v5.0.0
30+
31+ - uses : actions/setup-node@v6.3.0
32+ with :
33+ node-version : 20
34+ cache : pnpm
35+
36+ - name : Install dependencies
37+ run : pnpm install --frozen-lockfile
38+
39+ - name : Lint
40+ run : pnpm run lint
41+
42+ - name : Test
43+ run : pnpm run test
44+
45+ - name : Build
46+ run : pnpm run build
47+ env :
48+ STORYBOOK_BASE_PATH : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && format('/{0}/', github.event.repository.name) || '' }}
49+
50+ - name : Upload Storybook artifact
51+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
52+ uses : actions/upload-pages-artifact@v4.0.0
53+ with :
54+ path : apps/storybook/storybook-static
55+
56+ deploy-storybook :
57+ name : Deploy Storybook to GitHub Pages
58+ needs : ci
59+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
60+ runs-on : ubuntu-latest
61+ environment :
62+ name : github-pages
63+ url : ${{ steps.deployment.outputs.page_url }}
64+ steps :
65+ - name : Deploy to GitHub Pages
66+ id : deployment
67+ uses : actions/deploy-pages@v5.0.0
Original file line number Diff line number Diff line change 11import type { StorybookConfig } from "@storybook/react-vite" ;
2+
23const config : StorybookConfig = {
34 stories : [
45 "../src/**/*.mdx" ,
@@ -17,5 +18,12 @@ const config: StorybookConfig = {
1718 docs : {
1819 autodocs : "tag" ,
1920 } ,
21+ viteFinal : async ( config ) => {
22+ const base = process . env . STORYBOOK_BASE_PATH ?. trim ( ) ;
23+ if ( base ) {
24+ config . base = base . endsWith ( "/" ) ? base : `${ base } /` ;
25+ }
26+ return config ;
27+ } ,
2028} ;
2129export default config ;
You can’t perform that action at this time.
0 commit comments