From c032e2e951ced508efaf961918a727a41ab2b9cc Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Fri, 20 Jan 2023 12:06:18 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(react)=20publish=20storybook=20to=20g?= =?UTF-8?q?ithub=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to make the storybook visible to everyone. Some changes had to be made to make index.scss compiled with the rest of the codebase, it had to be imported from preview.js, not directly from preview.html. --- .circleci/config.yml | 27 ++++ packages/react/.storybook/main.cjs | 35 +++-- packages/react/.storybook/preview-head.html | 1 - packages/react/.storybook/preview.js | 2 + packages/react/package.json | 4 +- yarn.lock | 158 ++++++++++++++++++-- 6 files changed, 195 insertions(+), 32 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2217f91..79c46de 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -128,6 +128,26 @@ jobs: name: Run test suites over all workspaces command: yarn test + # ---- Deploy ---- + publish-storybook: + docker: + - image: cimg/node:16.18 + working_directory: ~/cunningham + steps: + - add_ssh_keys: + fingerprints: + - "5e:86:38:27:26:f2:1b:7f:4b:36:99:38:63:d9:2b:75" + - *checkout_cunningham + - *restore_node_modules + - attach_workspace: + at: ~/cunningham + - run: + name: Publish storybook + command: | + cd packages/react + git config user.email "funmoocbot@users.noreply.github.com" + git config user.name "FUN MOOC bot" + yarn deploy-storybook workflows: version: 2.1 @@ -177,3 +197,10 @@ workflows: requires: - build - lint + - publish-storybook: + filters: + branches: + only: + - main + requires: + - test \ No newline at end of file diff --git a/packages/react/.storybook/main.cjs b/packages/react/.storybook/main.cjs index 58eb6cc..1b1c7a1 100644 --- a/packages/react/.storybook/main.cjs +++ b/packages/react/.storybook/main.cjs @@ -1,33 +1,32 @@ const viteTsconfig = require('vite-tsconfig-paths'); const tsconfigPaths = viteTsconfig.default; - const { mergeConfig } = require('vite'); module.exports = { - "stories": [ - "../src/**/*.stories.mdx", - "../src/**/*.stories.@(js|jsx|ts|tsx)" + 'stories': [ + '../src/**/*.stories.mdx', + '../src/**/*.stories.@(js|jsx|ts|tsx)', ], - "addons": [ - "@storybook/addon-links", - "@storybook/addon-essentials", - "@storybook/addon-interactions", - '@storybook/preset-scss' + 'addons': [ + '@storybook/addon-links', + '@storybook/addon-essentials', + '@storybook/addon-interactions', ], - "framework": "@storybook/react", - "core": { - "builder": "@storybook/builder-vite" + 'framework': '@storybook/react', + 'core': { + 'builder': '@storybook/builder-vite', }, staticDirs: [ - 'dist', - '../src' + '../src', ], - "features": { - "storyStoreV7": true + 'features': { + 'storyStoreV7': true, }, async viteFinal(config) { - return mergeConfig(config, { + const finalConfig = mergeConfig(config, { plugins: [tsconfigPaths()], }); + finalConfig.base = 'https://openfun.github.io/cunningham'; + return finalConfig; }, -} \ No newline at end of file +}; \ No newline at end of file diff --git a/packages/react/.storybook/preview-head.html b/packages/react/.storybook/preview-head.html index 79c8a0d..037204a 100644 --- a/packages/react/.storybook/preview-head.html +++ b/packages/react/.storybook/preview-head.html @@ -1,4 +1,3 @@ -