Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Pages publish guide #24527

Merged
merged 16 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion docs/sharing/publish-storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,39 @@ When you publish Storybook, you also get component history and versioning down t

![Library history in Chromatic](./workflow-history-versioning.png)

## Publish to GitHub Pages

To deploy to GitHub Pages, simply use the [deploy-storybook-to-github-pages](https://github.com/marketplace/actions/deploy-storybook-to-github-pages) GitHub Action.

From your project's root directory, add a new file called `deploy-ghp.yml` inside the `.github/workflows` directory:
<!-- prettier-ignore-start -->

<CodeSnippets
paths={[
'common/ghp-github-action.js.mdx',
]}
/>

<!-- prettier-ignore-end -->


It does the build for you, and it publishes the built site to GitHub pages with the Actions based pages deployment.

The action has many customizable options including `install_command` (default is `npm ci`) and `build_command` (default is `npm run build-storybook`) and output directory.


<div class="aside">

ℹ️ Be sure to [set up your project](https://github.com/marketplace/actions/deploy-storybook-to-github-pages#set-up-your-project-for-actions-deployed-pages) for Actions-deployed pages!

</div>

Commit and push the file. Congratulations, you've successfully automated publishing your Storybook to GitHub Pages!


## Publish Storybook to other services

Since Storybook is built as a static web application, you can also publish it to any web host, including [GitHub Pages](https://docs.github.com/en/pages), [Netlify](https://www.netlify.com/), [AWS S3](https://aws.amazon.com/s3/), and more. However, features such as [Composition](./storybook-composition.md),
Since Storybook is built as a static web application, you can also publish it to any web host, including [Netlify](https://www.netlify.com/), [AWS S3](https://aws.amazon.com/s3/), and more. However, features such as [Composition](./storybook-composition.md),
[embedding stories](./embed.md), history, and versioning require tighter integration with Storybook APIs and secure authentication. Your hosting provider may not be capable of supporting these features. Learn about the Component Publishing Protocol (CPP) to see what.
mickmcgrath13 marked this conversation as resolved.
Show resolved Hide resolved

<div class="aside">
mickmcgrath13 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
26 changes: 26 additions & 0 deletions docs/snippets/common/ghp-github-action.js.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
```shell
mickmcgrath13 marked this conversation as resolved.
Show resolved Hide resolved
# .github/workflows/deploy-ghp.yml

# Workflow name
name: Build and Publish storybook to GitHub Pages

on:
# Event for the workflow
push:
branches:
- "main"

# List of jobs
jobs:
deploy:
# Operating System
runs-on: ubuntu-latest

# Job steps
steps:

#👇 Adds Storybook build and deploy to GitHub Pages as a step in the workflow
- uses: bitovi/[email protected]
with:
path: dist/storybook
```
mickmcgrath13 marked this conversation as resolved.
Show resolved Hide resolved