diff --git a/.storybook/main.js b/.storybook/main.js index 4a94895..1c12820 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -17,5 +17,9 @@ const config = { name: "@storybook/react-webpack5", options: {}, }, + env: (config) => ({ + ...config, + GITHUB_REPOSITORY: process.env["GITHUB_REPOSITORY"] || null, + }), }; export default config; diff --git a/.storybook/preview.js b/.storybook/preview.js index 2d821eb..7363c5e 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -1,4 +1,5 @@ /** @type { import('@storybook/react').Preview } */ +const isGithubBuild = !!process.env["GITHUB_REPOSITORY"] const preview = { parameters: { branches: { @@ -13,4 +14,11 @@ const preview = { }, }; +if (isGithubBuild) { + const [owner, repo] = process.env["GITHUB_REPOSITORY"].split("/") + preview.parameters["branches"] = { + hostname: `${owner}.github.io/${repo}`, + } +} + export default preview;