Skip to content

Deploy React storybook to GitHub Pages #184

Deploy React storybook to GitHub Pages

Deploy React storybook to GitHub Pages #184

name: Deploy React storybook to GitHub Pages
on:
workflow_dispatch:
push:
tags:
# Matches tags that have the shape `vX.Y.Z`. Reference:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#onpushpull_requesttagsbranches
- 'v[0-9]+.[0-9]+.[0-9]+'
# Ignore tags that use a preid after `vX.Y.Z`, for example: vX.Y.Z-alpha.0
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#example-using-positive-and-negative-patterns
- '!v[0-9]+.[0-9]+.[0-9]+-*'
- '!v10*'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
- name: Use Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 #v4.0.2
with:
node-version: '20.x'
- name: Install dependencies
run: yarn install --immutable --immutable-cache
- name: Build project
run: yarn build
- name: Build React storybook
run: |
cd packages/react
yarn storybook:build
- name: Setup Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b #v5.0.0
- name: Fix permissions
run: |
chmod -v -R +rX "_site/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa #v3.0.1
with:
path: 'packages/react/storybook-static'
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e #v4.0.5