Skip to content

Fix sb links (#1164) #2944

Fix sb links (#1164)

Fix sb links (#1164) #2944

# This workflow publishes storybook to GitHub pages
name: Publish Storybook
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
jobs:
publish-storybook:
runs-on: ubuntu-latest
env:
dest: ${{ github.event.number || github.ref == 'refs/heads/master' && 'storybook' || '' }}
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Configure git
run: |
git config --local user.email imodeljs-admin@users.noreply.github.com
git config --local user.name imodeljs-admin
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Rush install
run: node common/scripts/install-run-rush.js install
- name: Rush build
run: node common/scripts/install-run-rush.js build -v -p max --to-except appui-storybook
- name: Build storybook
run: npm run build:storybook
working-directory: docs/storybook
- name: List of gh-pages to preserve
id: clean_exclude_folders
uses: actions/github-script@v4
with:
result-encoding: string
script: |
return ['/index.html', 'storybook', ...((await github.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
})).data.map(pr => pr.number))].join('\n')
- name: Create an empty folder
run: |
mkdir emptyFolder
- name: Clean gh-pages
uses: JamesIves/github-pages-deploy-action@v4
if: env.dest == 'storybook'
with:
branch: gh-pages
folder: emptyFolder
single-commit: true
clean-exclude: ${{ steps.clean_exclude_folders.outputs.result }}
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
if: env.dest != ''
with:
branch: gh-pages
folder: docs/storybook/storybook-static
target-folder: ${{ env.dest }}
single-commit: true
clean: true
- name: Post link
if: github.event.number
uses: actions/github-script@v6
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ github.event.pull_request.head.sha }}',
state: 'success',
context: 'Storybook preview',
description: 'Storybook preview of the current branch',
target_url: 'https://itwin.github.io/appui/${{ github.event.number }}',
})