Skip to content

Commit

Permalink
Merge pull request #8 from CivicTechTO/6-branch-switcher-addon
Browse files Browse the repository at this point in the history
Add ability to deploy storybook branches to github pages
  • Loading branch information
patcon authored Oct 6, 2024
2 parents 39cfc28 + 4fa0fb0 commit 25fc923
Show file tree
Hide file tree
Showing 7 changed files with 537 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/deploy-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- 'main'
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read
Expand All @@ -18,8 +20,10 @@ jobs:
with:
submodules: true

# See: https://github.com/bitovi/github-actions-storybook-to-github-pages
- uses: bitovi/[email protected]
with:
path: storybook-static
build_command: "npm run build-storybook && npx sb-branch-switcher --config .storybook/.branches.json"
path: dist/storybook-bundle
# Done manually so we can checkout submodule
checkout: false
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/node_modules
/storybook-static
/node_modules/
/dist/
.DS_Store
12 changes: 12 additions & 0 deletions .storybook/.branches.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"from": "storybook-static",
"to": "dist/storybook-bundle",
"script_name": "build-storybook-branch",
"default_branch": "main",
"default_root": true,
"provider": {
"type": "github",
"owner": "CivicTechTO",
"repository": "polis-storybook"
}
}
1 change: 1 addition & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const config = {
"@chromatic-com/storybook",
"@storybook/addon-interactions",
"storybook-addon-remix-react-router",
"storybook-branch-switcher",
],
framework: {
name: "@storybook/react-webpack5",
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ setup: ## Install packages and polis codebase
run: ## Run storybook development environment
npm run storybook

build: ## Build static storybook for deploy
npm run build-storybook

build-all-branches: ## Build static storybook for all PR branches (requires GITHUB_TOKEN)
npm run build-storybook
npx sb-branch-switch --config .storybook/.branches.json

%:
@true

Expand Down
Loading

0 comments on commit 25fc923

Please sign in to comment.